From 2a2c76a02835578b9edcd73a7cff88a5bab2576e Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Mon, 22 Apr 2024 11:45:03 +0200 Subject: [PATCH] [FIX] l10n_sa_edi: fix scheme ID for foreign customers Steps to reproduce: - Install Contacts, Accounting and l10n_sa_edi - Switch to a Saudi Arabian company (e.g. SA Company) - Create a contact who is not in Saudi Arabia: * Address: [Complete address in United Arab Emirates] * VAT: [any] - Create an invoice: * Customer: [The created contact] * Product: [any] - Confirm the invoice - Process by ZATCA Issue: The following warning is returned: "The other Buyer ID (BT-46) must present in the tax invoice and associated debit notes and credit notes (KSA-2, position 1 and 2 = 01), where the buyer VAT registration number or buyer group VAT registration number (BT-48) is not provided." Cause: "PartyIdentification" element is not set in the electronic invoice for customer because he doesn't have "l10n_sa_additional_identification_number" field set. This field is only available for contacts living in Saudi Arabia. For contacts who don't live in Saudi Arabia, "PartyIdentification" should be populate with their VAT number. opw-3845645 closes odoo/odoo#163652 X-original-commit: 3500c5f5dc78ea88bb662bb08cb6c59482f502db Signed-off-by: Brice Bartoletti (bib) --- addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py | 6 +++++- addons/l10n_sa_edi/tests/compliance/standard/credit.xml | 3 --- addons/l10n_sa_edi/tests/compliance/standard/debit.xml | 3 --- addons/l10n_sa_edi/tests/compliance/standard/invoice.xml | 3 ++- addons/l10n_sa_edi/tests/test_edi_zatca.py | 1 + 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py b/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py index e6482eef052..2cadd82f034 100644 --- a/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py +++ b/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py @@ -104,7 +104,11 @@ class AccountEdiXmlUBL21Zatca(models.AbstractModel): """ Override to include/update values specific to ZATCA's UBL 2.1 specs """ return [{ 'id_attrs': {'schemeID': partner.l10n_sa_additional_identification_scheme}, - 'id': partner.l10n_sa_additional_identification_number if partner.l10n_sa_additional_identification_scheme != 'TIN' else partner.vat + 'id': ( + partner.l10n_sa_additional_identification_number + if partner.l10n_sa_additional_identification_scheme != 'TIN' and partner.country_code == 'SA' + else partner.vat + ), }] def _l10n_sa_get_payment_means_code(self, invoice): diff --git a/addons/l10n_sa_edi/tests/compliance/standard/credit.xml b/addons/l10n_sa_edi/tests/compliance/standard/credit.xml index dc3da47e48e..f5447b9b7f3 100644 --- a/addons/l10n_sa_edi/tests/compliance/standard/credit.xml +++ b/addons/l10n_sa_edi/tests/compliance/standard/credit.xml @@ -102,9 +102,6 @@ - - 353535353535353 - Chichi Lboukla diff --git a/addons/l10n_sa_edi/tests/compliance/standard/debit.xml b/addons/l10n_sa_edi/tests/compliance/standard/debit.xml index 690cedce8c0..ee4cc740125 100644 --- a/addons/l10n_sa_edi/tests/compliance/standard/debit.xml +++ b/addons/l10n_sa_edi/tests/compliance/standard/debit.xml @@ -102,9 +102,6 @@ - - 353535353535353 - Chichi Lboukla diff --git a/addons/l10n_sa_edi/tests/compliance/standard/invoice.xml b/addons/l10n_sa_edi/tests/compliance/standard/invoice.xml index a8cefd0386f..f1c4d6c77be 100644 --- a/addons/l10n_sa_edi/tests/compliance/standard/invoice.xml +++ b/addons/l10n_sa_edi/tests/compliance/standard/invoice.xml @@ -97,7 +97,7 @@ - 353535353535353 + US12345677 Chichi Lboukla @@ -118,6 +118,7 @@ Chichi Lboukla + US12345677 4557 De Silva St 12300 diff --git a/addons/l10n_sa_edi/tests/test_edi_zatca.py b/addons/l10n_sa_edi/tests/test_edi_zatca.py index fc79a3c7e2d..ec5885da31e 100644 --- a/addons/l10n_sa_edi/tests/test_edi_zatca.py +++ b/addons/l10n_sa_edi/tests/test_edi_zatca.py @@ -22,6 +22,7 @@ class TestEdiZatca(TestSaEdiCommon): expected_tree = self.get_xml_tree_from_string(standard_invoice) expected_tree = self.with_applied_xpath(expected_tree, self.invoice_applied_xpath) + self.partner_us.vat = 'US12345677' move = self._create_invoice(name='INV/2022/00014', date='2022-09-05', date_due='2022-09-22', partner_id=self.partner_us, product_id=self.product_a, price=320.0) move._l10n_sa_generate_unsigned_data()