Skip to content

Commit 2a157ae

Browse files
committed
[FIX] l10n_tr_nilvera_einvoice: exclude ID without schemeID
Nilvera expects a <schemeID> with every <ID>. In Odoo currently, we only support VKN or TCKN as a schemeID that get impacted from the VAT Number. Also, Nilvera reject any <BuyerReference> tag. Before: - The generated XML contains some <ID> tags without 'schemeID' attribute. - The generated XML contains some <BuyerReference> tag. After: - The <ID> tags with no 'schemeID' are removed from the XML. - The <BuyerReference> tag is removed from the XML. Task-4822777 closes odoo#214501 Signed-off-by: Maximilien La Barre (malb) <[email protected]>
1 parent dd3679b commit 2a157ae

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

addons/l10n_tr_nilvera_einvoice/models/account_edi_xml_ubl_tr.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def _get_formatted_id(invoice):
4242
'pricing_currency_code': invoice.currency_id.name.upper() if invoice.currency_id != invoice.company_id.currency_id else False,
4343
'currency_dp': 2,
4444
})
45+
# Nilvera will reject any <BuyerReference> tag, so remove it
46+
if vals['vals'].get('buyer_reference'):
47+
del vals['vals']['buyer_reference']
4548
return vals
4649

4750
def _get_country_vals(self, country):
@@ -53,6 +56,9 @@ def _get_country_vals(self, country):
5356
def _get_partner_party_identification_vals_list(self, partner):
5457
# EXTENDS account.edi.xml.ubl_21
5558
vals = super()._get_partner_party_identification_vals_list(partner)
59+
# Nilvera will reject any <ID> without a <schemeID>, so remove all items not
60+
# having the following structure : {'id': '...', 'id_attrs': {'schemeID': '...'}}
61+
vals = [v for v in vals if v.get('id') and v.get('id_attrs', {}).get('schemeID')]
5662
vals.append({
5763
'id_attrs': {
5864
'schemeID': 'VKN' if partner.is_company else 'TCKN',

addons/l10n_tr_nilvera_einvoice/tests/test_xml_ubl_tr.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def _generate_invoice_xml(self, **kwargs):
8181

8282
def test_xml_invoice_einvoice(self):
8383
with freeze_time('2025-03-05'):
84+
# Adding a ref field to the partner because this field has an influence on <BuyerReference> and
85+
# <PartyIdentification> tags in UBL but we have special code to not take it into account for UBL TR 1.2
86+
self.partner_1.ref = '1234567890'
8487
generated_xml = self._generate_invoice_xml()
8588

8689
with file_open('l10n_tr_nilvera_einvoice/tests/expected_xmls/invoice_einvoice.xml', 'rb') as expected_xml_file:

0 commit comments

Comments
 (0)