odoo/odoo#189717

Created by fw-bot
Merged at acf4f327ffc24e5f20826bc44445bac45cca65fe

Statuses:

label
odoo-dev:17.0-16.0-opw-4261026-xrechnung_fallback_email-pta-TMxW-fw
head
9237e308e2580715d7b1be896b5ad4f278f1a099
merged
1 year ago by Bugfix, Anh Thao Pham (pta)
odoo/odoo
16.0 #189183
17.0 #189717
saas-17.2 #189747
saas-17.4 #189771
18.0 #189791
saas-18.2
saas-18.3
saas-18.4
19.0
master #189804

[FW][FIX] {l10n_}account_edi_ubl_cii{_tests}: email as electronic address for xrechnung

Steps to reproduce:
- Install Accounting and l10n_de
- Switch to a German company
- Configure the customer invoice journal to enable "XRechnung UBL (Germany)"
- Create a German contact:
* with a complete address
* with an email address
* without a VAT number
- Create an invoice for the created contact
- Confirm the invoice
- Generate the electronic invoice
- Validate the generated XML on an online XRechnung ValidationError

Issue:
The XRechnung (UBL Invoice) is not valid because the buyer electronic address is missing (cbc:EndpointID).

Cause:
<cbc:EndpointID> gets its value from contact's VAT, but the contact has no VAT.

Solution:
Since XRechnung 3.0.1, the email address can be used as electronic address with "EM" as schemeID.
So, fallback on email address if contact has no VAT.

Reference:
https://www.e-rechnung-bund.de/standard-xrechnung-3-0-1/
https://blog.seeburger.com/xrechnung-version-3-0-1-comes-into-force-on-february-1-2024/
https://erechnungsvalidator.service-bw.de/

opw-4261026


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #189183