[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) <yosa@odoo.com>
This commit is contained in:
yosa-odoo
2024-02-19 17:53:16 +00:00
parent 5f51ed9ad9
commit a7f9eb3127
8 changed files with 13 additions and 8 deletions
@@ -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,
}
@@ -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 [{
@@ -101,7 +101,7 @@
<cac:Contact>
<cbc:ID>1</cbc:ID>
<cbc:Name>SA Company Test</cbc:Name>
<cbc:Telephone>+966 51 234 5678</cbc:Telephone>
<cbc:Telephone>+966512345678</cbc:Telephone>
<cbc:ElectronicMail>info@company.saexample.com</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
@@ -101,7 +101,7 @@
<cac:Contact>
<cbc:ID>1</cbc:ID>
<cbc:Name>SA Company Test</cbc:Name>
<cbc:Telephone>+966 51 234 5678</cbc:Telephone>
<cbc:Telephone>+966512345678</cbc:Telephone>
<cbc:ElectronicMail>info@company.saexample.com</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
@@ -96,7 +96,7 @@
<cac:Contact>
<cbc:ID>1</cbc:ID>
<cbc:Name>SA Company Test</cbc:Name>
<cbc:Telephone>+966 51 234 5678</cbc:Telephone>
<cbc:Telephone>+966512345678</cbc:Telephone>
<cbc:ElectronicMail>info@company.saexample.com</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
@@ -95,7 +95,7 @@
<cac:Contact>
<cbc:ID>337</cbc:ID>
<cbc:Name>SA Company Test</cbc:Name>
<cbc:Telephone>+966 51 234 5678</cbc:Telephone>
<cbc:Telephone>+966512345678</cbc:Telephone>
<cbc:ElectronicMail>info@company.saexample.com</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
@@ -95,7 +95,7 @@
<cac:Contact>
<cbc:ID>547</cbc:ID>
<cbc:Name>SA Company Test</cbc:Name>
<cbc:Telephone>+966 51 234 5678</cbc:Telephone>
<cbc:Telephone>+966512345678</cbc:Telephone>
<cbc:ElectronicMail>info@company.saexample.com</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
@@ -89,7 +89,7 @@
<cac:Contact>
<cbc:ID>33</cbc:ID>
<cbc:Name>SA Company Test</cbc:Name>
<cbc:Telephone>+966 51 234 5678</cbc:Telephone>
<cbc:Telephone>+966512345678</cbc:Telephone>
<cbc:ElectronicMail>info@company.saexample.com</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>