diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml
index daf07495a4e..d028fb698d5 100644
--- a/addons/l10n_it_edi/data/invoice_it_template.xml
+++ b/addons/l10n_it_edi/data/invoice_it_template.xml
@@ -8,18 +8,18 @@
EAN
-
+
INTERNAL
-
+
-
+
-
+
@@ -36,9 +36,9 @@
-
+
-
+
@@ -54,14 +54,14 @@
-
+
-
-
+
+
@@ -74,7 +74,7 @@
-
+
@@ -84,7 +84,7 @@
-
+
@@ -99,9 +99,9 @@
-
-
-
+
+
+
@@ -122,9 +122,9 @@
-
-
-
+
+
+
@@ -139,7 +139,7 @@
-
+
SI
@@ -147,11 +147,11 @@
-
+
-
+
@@ -172,7 +172,7 @@
-
+
@@ -185,15 +185,15 @@
MP05
-
+
-
+
-
+
PDF
diff --git a/addons/l10n_it_edi/models/account_invoice.py b/addons/l10n_it_edi/models/account_invoice.py
index e5d40b4c1fa..6f9412a513a 100644
--- a/addons/l10n_it_edi/models/account_invoice.py
+++ b/addons/l10n_it_edi/models/account_invoice.py
@@ -142,6 +142,9 @@ class AccountMove(models.Model):
return True
return False
+ def format_alphanumeric(text_to_convert):
+ return text_to_convert.encode('latin-1', 'replace').decode('latin-1') if text_to_convert else False
+
formato_trasmissione = "FPA12" if self._is_commercial_partner_pa() else "FPR12"
if self.move_type == 'out_invoice':
@@ -179,6 +182,7 @@ class AccountMove(models.Model):
'format_numbers': format_numbers,
'format_numbers_two': format_numbers_two,
'format_phone': format_phone,
+ 'format_alphanumeric': format_alphanumeric,
'discount_type': discount_type,
'get_vat_number': get_vat_number,
'get_vat_country': get_vat_country,
diff --git a/addons/l10n_it_edi_sdicoop/tests/expected_xmls/IT00470550013_basis.xml b/addons/l10n_it_edi_sdicoop/tests/expected_xmls/IT00470550013_basis.xml
index 56c49b87938..7930605299e 100644
--- a/addons/l10n_it_edi_sdicoop/tests/expected_xmls/IT00470550013_basis.xml
+++ b/addons/l10n_it_edi_sdicoop/tests/expected_xmls/IT00470550013_basis.xml
@@ -37,8 +37,7 @@
00465840031
- Alessi
-
+ Alessi
diff --git a/addons/l10n_it_edi_sdicoop/tests/test_edi_xml.py b/addons/l10n_it_edi_sdicoop/tests/test_edi_xml.py
index 4aa2bb3ef15..f70f7ff57a0 100644
--- a/addons/l10n_it_edi_sdicoop/tests/test_edi_xml.py
+++ b/addons/l10n_it_edi_sdicoop/tests/test_edi_xml.py
@@ -55,6 +55,7 @@ class TestItEdi(AccountEdiTestCommon):
'zip': '28887',
'city': 'Milan',
'company_id': cls.company.id,
+ 'is_company': True,
})
cls.standard_line = {
@@ -124,6 +125,27 @@ class TestItEdi(AccountEdiTestCommon):
],
})
+ cls.non_latin_and_latin_invoice = cls.env['account.move'].with_company(cls.company).create({
+ 'move_type': 'out_invoice',
+ 'invoice_date': datetime.date(2022, 3, 24),
+ 'partner_id': cls.italian_partner_a.id,
+ 'partner_bank_id': cls.test_bank.id,
+ 'invoice_line_ids': [
+ (0, 0, {
+ **cls.standard_line,
+ 'name': 'ʢ◉ᴥ◉ʡ',
+ }),
+ (0, 0, {
+ **cls.standard_line,
+ 'name': '–-',
+ }),
+ (0, 0, {
+ **cls.standard_line,
+ 'name': 'this should be the same as it was',
+ }),
+ ],
+ })
+
# We create this because we are unable to post without a proxy user existing
cls.proxy_user = cls.env['account_edi_proxy_client.user'].create({
'id_client': 'l10n_it_edi_sdicoop_test',
@@ -137,6 +159,7 @@ class TestItEdi(AccountEdiTestCommon):
cls.price_included_invoice._post()
cls.partial_discount_invoice._post()
cls.full_discount_invoice._post()
+ cls.non_latin_and_latin_invoice._post()
cls.edi_basis_xml = cls._get_test_file_content('IT00470550013_basis.xml')
@@ -316,3 +339,50 @@ class TestItEdi(AccountEdiTestCommon):
''')
invoice_etree = self.with_applied_xpath(invoice_etree, "")
self.assertXmlTreeEqual(invoice_etree, expected_etree)
+
+ @freeze_time('2020-03-24')
+ def test_non_latin_and_latin_inovice(self):
+ invoice_etree = etree.fromstring(self.non_latin_and_latin_invoice._export_as_xml())
+ expected_etree = self.with_applied_xpath(
+ etree.fromstring(self.edi_basis_xml),
+ '''
+
+
+
+ 1
+ ?????
+ 1.00
+ 800.400000
+ 800.40
+ 22.00
+
+
+ 2
+ ?-
+ 1.00
+ 800.400000
+ 800.40
+ 22.00
+
+
+ 3
+ this should be the same as it was
+ 1.00
+ 800.400000
+ 800.40
+ 22.00
+
+
+ 22.00
+ 2401.20
+ 528.27
+ I
+
+
+
+
+ 2929.47
+
+ ''')
+ invoice_etree = self.with_applied_xpath(invoice_etree, "")
+ self.assertXmlTreeEqual(invoice_etree, expected_etree)