From f99c93b5ce36e3eac19c7d79c4f6434b458ea066 Mon Sep 17 00:00:00 2001 From: dbkosky Date: Mon, 9 May 2022 13:11:51 +0000 Subject: [PATCH] [FIX] l10n_it_edi: double IT country code filename The current problem is that the codice fiscale field is validated using a regex that matches an alphanumeric code of 16 digits (that causes no problems) and both a simple numeric code (of 11 digits) and an alphanumeric code (of 13 digits, starting with the country code 'IT') for businesses. The problem is that the systems that make use of the codice fiscale code tend to utilise the former (i.e. the 11 digit code, without the 'IT' prefix). The filename for the EDI comprises a country code, the codice fiscale of the company and a progressive number. When the codice fiscale is completed as being eg. 'IT00465840031', the country code + codice fiscale will be 'ITIT00465840031', which will be rejected by the edi system (a single country code is expected). This commit removes the 'IT' in the xml by utilising a function on the template _l10n_it_normalize_codice_fiscale from the res.partner model. related ticket-id: 2845341 closes odoo/odoo#91370 X-original-commit: 39dcee1cc1ef1ed4c4a85494b689f4f604e32de6 Signed-off-by: Josse Colpaert --- .../l10n_it_edi/data/invoice_it_simplified_template.xml | 8 ++++---- addons/l10n_it_edi/data/invoice_it_template.xml | 8 ++++---- addons/l10n_it_edi/models/account_edi_format.py | 2 +- addons/l10n_it_edi/models/account_invoice.py | 1 + 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/l10n_it_edi/data/invoice_it_simplified_template.xml b/addons/l10n_it_edi/data/invoice_it_simplified_template.xml index 0c1a8428333..5d811cbf386 100644 --- a/addons/l10n_it_edi/data/invoice_it_simplified_template.xml +++ b/addons/l10n_it_edi/data/invoice_it_simplified_template.xml @@ -23,7 +23,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -99,4 +99,4 @@ - \ No newline at end of file + diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml index d028fb698d5..627e5cfd2aa 100644 --- a/addons/l10n_it_edi/data/invoice_it_template.xml +++ b/addons/l10n_it_edi/data/invoice_it_template.xml @@ -52,7 +52,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -97,7 +97,7 @@ - + @@ -119,7 +119,7 @@ - + diff --git a/addons/l10n_it_edi/models/account_edi_format.py b/addons/l10n_it_edi/models/account_edi_format.py index 76379eb4d00..870840b81b9 100644 --- a/addons/l10n_it_edi/models/account_edi_format.py +++ b/addons/l10n_it_edi/models/account_edi_format.py @@ -54,7 +54,7 @@ class AccountEdiFormat(models.Model): return '%(country_code)s%(codice)s_%(progressive_number)s.xml' % { 'country_code': invoice.company_id.country_id.code, - 'codice': invoice.company_id.l10n_it_codice_fiscale.replace(' ', ''), + 'codice': self.env['res.partner']._l10n_it_normalize_codice_fiscale(invoice.company_id.l10n_it_codice_fiscale), 'progressive_number': progressive_number.zfill(5), } diff --git a/addons/l10n_it_edi/models/account_invoice.py b/addons/l10n_it_edi/models/account_invoice.py index 6bcdaeafa06..80e653fb051 100644 --- a/addons/l10n_it_edi/models/account_invoice.py +++ b/addons/l10n_it_edi/models/account_invoice.py @@ -180,6 +180,7 @@ class AccountMove(models.Model): 'format_numbers_two': format_numbers_two, 'format_phone': format_phone, 'format_alphanumeric': format_alphanumeric, + 'normalize_codice_fiscale': self.env['res.partner']._l10n_it_normalize_codice_fiscale, 'discount_type': discount_type, 'get_vat_number': get_vat_number, 'get_vat_country': get_vat_country,