From a7f9eb31271d6830c9ed2b63bf8944f4188c131d Mon Sep 17 00:00:00 2001 From: yosa-odoo Date: Wed, 7 Feb 2024 14:33:35 +0100 Subject: [PATCH] [FIX] account_edi_ubl_cii, l10n_sa_edi: preventing format from phonenumbers Steps to reproduce: [l10n_sa_edi] [phonenumbers must be pip installed] - create a customer with all needed information - create an invoice with the customer - confirm and process Issue: There will be a warning Cause: `phonenumbers` format the phone numbers with spaces -> len(phone) > max size authorized by api Note: revert the https://github.com/odoo/odoo/pull/148124 and only apply the fix for l10n_sa_edi in order to avoid test break from https://github.com/odoo/odoo/blob/dceaf735fd2e46342dcd144c1969853a55d7b661/addons/l10n_account_edi_ubl_cii_tests/tests/test_xml_ubl_de.py#L104 opw-3666195 closes odoo/odoo#154618 X-original-commit: 5d845bd18359c7601e2a45686156855c6d0b2ace Signed-off-by: Yolann Sabaux (yosa) --- addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py | 3 +-- addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py | 6 ++++++ addons/l10n_sa_edi/tests/compliance/simplified/credit.xml | 2 +- addons/l10n_sa_edi/tests/compliance/simplified/debit.xml | 2 +- addons/l10n_sa_edi/tests/compliance/simplified/invoice.xml | 2 +- addons/l10n_sa_edi/tests/compliance/standard/credit.xml | 2 +- addons/l10n_sa_edi/tests/compliance/standard/debit.xml | 2 +- addons/l10n_sa_edi/tests/compliance/standard/invoice.xml | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py index 686704fd370..3bb75c72ff5 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py @@ -67,11 +67,10 @@ class AccountEdiXmlUBL20(models.AbstractModel): }] def _get_partner_contact_vals(self, partner): - phone = partner.phone or partner.mobile return { 'id': partner.id, 'name': partner.name, - 'telephone': phone and phone.strip(), + 'telephone': partner.phone or partner.mobile, 'electronic_mail': partner.email, } 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 84c8b4c85af..e6482eef052 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 @@ -94,6 +94,12 @@ class AccountEdiXmlUBL21Zatca(models.AbstractModel): return [{'actual_delivery_date': invoice.delivery_date or invoice.invoice_date, 'delivery_address_vals': self._get_partner_address_vals(shipping_address) if shipping_address else {},}] + def _get_partner_contact_vals(self, partner): + res = super()._get_partner_contact_vals(partner) + if res.get('telephone'): + res['telephone'] = res['telephone'].replace(' ', '') + return res + def _get_partner_party_identification_vals_list(self, partner): """ Override to include/update values specific to ZATCA's UBL 2.1 specs """ return [{ diff --git a/addons/l10n_sa_edi/tests/compliance/simplified/credit.xml b/addons/l10n_sa_edi/tests/compliance/simplified/credit.xml index 4397c2e53f8..3a8a785246f 100644 --- a/addons/l10n_sa_edi/tests/compliance/simplified/credit.xml +++ b/addons/l10n_sa_edi/tests/compliance/simplified/credit.xml @@ -101,7 +101,7 @@ 1 SA Company Test - +966 51 234 5678 + +966512345678 info@company.saexample.com diff --git a/addons/l10n_sa_edi/tests/compliance/simplified/debit.xml b/addons/l10n_sa_edi/tests/compliance/simplified/debit.xml index b89bb2b738e..b6349951ab0 100644 --- a/addons/l10n_sa_edi/tests/compliance/simplified/debit.xml +++ b/addons/l10n_sa_edi/tests/compliance/simplified/debit.xml @@ -101,7 +101,7 @@ 1 SA Company Test - +966 51 234 5678 + +966512345678 info@company.saexample.com diff --git a/addons/l10n_sa_edi/tests/compliance/simplified/invoice.xml b/addons/l10n_sa_edi/tests/compliance/simplified/invoice.xml index cf8facbfa33..28c294e86b1 100644 --- a/addons/l10n_sa_edi/tests/compliance/simplified/invoice.xml +++ b/addons/l10n_sa_edi/tests/compliance/simplified/invoice.xml @@ -96,7 +96,7 @@ 1 SA Company Test - +966 51 234 5678 + +966512345678 info@company.saexample.com diff --git a/addons/l10n_sa_edi/tests/compliance/standard/credit.xml b/addons/l10n_sa_edi/tests/compliance/standard/credit.xml index 0db2edb6f76..dc3da47e48e 100644 --- a/addons/l10n_sa_edi/tests/compliance/standard/credit.xml +++ b/addons/l10n_sa_edi/tests/compliance/standard/credit.xml @@ -95,7 +95,7 @@ 337 SA Company Test - +966 51 234 5678 + +966512345678 info@company.saexample.com diff --git a/addons/l10n_sa_edi/tests/compliance/standard/debit.xml b/addons/l10n_sa_edi/tests/compliance/standard/debit.xml index 4b314353233..690cedce8c0 100644 --- a/addons/l10n_sa_edi/tests/compliance/standard/debit.xml +++ b/addons/l10n_sa_edi/tests/compliance/standard/debit.xml @@ -95,7 +95,7 @@ 547 SA Company Test - +966 51 234 5678 + +966512345678 info@company.saexample.com diff --git a/addons/l10n_sa_edi/tests/compliance/standard/invoice.xml b/addons/l10n_sa_edi/tests/compliance/standard/invoice.xml index 6fe81700176..a8cefd0386f 100644 --- a/addons/l10n_sa_edi/tests/compliance/standard/invoice.xml +++ b/addons/l10n_sa_edi/tests/compliance/standard/invoice.xml @@ -89,7 +89,7 @@ 33 SA Company Test - +966 51 234 5678 + +966512345678 info@company.saexample.com