From d97a52cd1b53d175f3fbd535b865b0c9d8aed6bf Mon Sep 17 00:00:00 2001 From: Brice bib Bartoletti Date: Fri, 20 Oct 2023 19:23:54 +0200 Subject: [PATCH] [FIX] {l10n_}account_edi_ubl_cii/dk_oioubl/ro_edi{_tests}: remove DocumentTypeCode from standard The aim of this commit to fix our bis3 e-invoice by setting the DocumentTypeCode node only for the EDIs that fills its values otherwise not setting that nodes. Currently, we only set it for Denmark as it is mandatory, for Romania because it was developped with it on the standard and we don't set it for the others to be defensive. (Because it's not mandatory) Before this commit: All e-invoice based on BIS3 gets rejected. After this commit: BIS3 e-invoice pass the validation again. Additional information: Bis3 DocumentTypeCode node: https://docs.peppol.eu/poacc/billing/3.0/syntax/ubl-invoice/cac-AdditionalDocumentReference/cbc-DocumentTypeCode/ UBL 2.0 DocumentTypeCode node: http://www.datypic.com/sc/ubl20/e-cbc_DocumentTypeCode.html UBL 2.2 DocumentTypeCode node: http://www.datypic.com/sc/ubl22/e-cbc_DocumentTypeCode.html closes odoo/odoo#139468 Task-id: 3563754 X-original-commit: 1da22571c43fceedb4ab8c13aa9d0d6a78372595 Signed-off-by: Florian Gilbert (flg) Signed-off-by: Brice Bartoletti (bib) --- .../account_edi_ubl_cii/models/account_edi_xml_ubl_20.py | 4 +--- addons/account_edi_ubl_cii/models/account_move_send.py | 9 +++++---- .../tests/test_files/from_odoo/a_nz_out_invoice.xml | 1 - .../tests/test_files/from_odoo/a_nz_out_refund.xml | 1 - .../tests/test_files/from_odoo/bis3_ecotaxes_case1.xml | 1 - .../tests/test_files/from_odoo/bis3_ecotaxes_case2.xml | 1 - .../tests/test_files/from_odoo/bis3_ecotaxes_case3.xml | 1 - .../tests/test_files/from_odoo/bis3_out_invoice.xml | 1 - .../from_odoo/bis3_out_invoice_public_admin.xml | 1 - .../test_files/from_odoo/bis3_out_invoice_rounding.xml | 1 - .../tests/test_files/from_odoo/bis3_out_refund.xml | 1 - .../tests/test_files/from_odoo/bis3_pay_term.xml | 1 - .../tests/test_files/from_odoo/bis3_pay_term_ecotax.xml | 1 - .../tests/test_files/from_odoo/nlcius_out_invoice.xml | 1 - .../tests/test_files/from_odoo/nlcius_out_refund.xml | 1 - .../test_files/from_odoo/xrechnung_ubl_out_invoice.xml | 1 - .../test_files/from_odoo/xrechnung_ubl_out_refund.xml | 1 - .../from_peppol-bis-invoice-3_doc/bis3_allowance.xml | 1 - .../l10n_dk_oioubl/models/account_edi_xml_oioubl_201.py | 1 + addons/l10n_ro_edi/models/account_edi_xml_ubl_ciusro.py | 7 +++++++ 20 files changed, 14 insertions(+), 23 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 0077d78d02f..96a32c9cf9a 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 @@ -595,9 +595,7 @@ class AccountEdiXmlUBL20(models.AbstractModel): def _get_document_type_code_vals(self, invoice, invoice_data): """Returns the values used for the `DocumentTypeCode` node""" # To be overriden by custom format if required - # http://www.datypic.com/sc/ubl20/e-cbc_DocumentTypeCode.html - document_type_code = 380 if invoice.move_type == 'out_invoice' else 381 - return {'attrs': {}, 'value': document_type_code} + return {'attrs': {}, 'value': None} # ------------------------------------------------------------------------- # IMPORT diff --git a/addons/account_edi_ubl_cii/models/account_move_send.py b/addons/account_edi_ubl_cii/models/account_move_send.py index 207bfa45a15..a849640e30d 100644 --- a/addons/account_edi_ubl_cii/models/account_move_send.py +++ b/addons/account_edi_ubl_cii/models/account_move_send.py @@ -191,18 +191,19 @@ class AccountMoveSend(models.TransientModel): filename = pdf_values['name'] content = pdf_values['raw'] + doc_type_node = "" edi_model = invoice_data["ubl_cii_xml_options"]["builder"] doc_type_code_vals = edi_model._get_document_type_code_vals(invoice, invoice_data) - document_type_code_attributes = " ".join(f'{name}="{value}"' for name, value in doc_type_code_vals['attrs'].items()) - document_type_code_value = doc_type_code_vals.get('value', '') - + if doc_type_code_vals['value']: + doc_type_code_attrs = " ".join(f'{name}="{value}"' for name, value in doc_type_code_vals['attrs'].items()) + doc_type_node = f"{doc_type_code_vals['value']}" to_inject = f''' {escape(filename)} - {document_type_code_value} + {doc_type_node} ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/a_nz_out_refund.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/a_nz_out_refund.xml index f3b949ac14c..4bacba99f0d 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/a_nz_out_refund.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/a_nz_out_refund.xml @@ -13,7 +13,6 @@ ___ignore___ - 381 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case1.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case1.xml index 6c5cacfe333..78afe53ba56 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case1.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case1.xml @@ -17,7 +17,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case2.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case2.xml index 9e18bb96942..f12e6b5e3c9 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case2.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case2.xml @@ -17,7 +17,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case3.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case3.xml index 46af1311019..47c21e1cdfb 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case3.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_ecotaxes_case3.xml @@ -17,7 +17,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice.xml index a63eea5b083..e0082b96543 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice.xml @@ -14,7 +14,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_public_admin.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_public_admin.xml index 6c3ac92d8a2..40f49d2ebc8 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_public_admin.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_public_admin.xml @@ -14,7 +14,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_rounding.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_rounding.xml index 51bf3db15ec..5b2a754179d 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_rounding.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_rounding.xml @@ -17,7 +17,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_refund.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_refund.xml index 7eff2616951..32a7dd45e8a 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_refund.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_refund.xml @@ -13,7 +13,6 @@ ___ignore___ - 381 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_pay_term.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_pay_term.xml index a95895663a0..e3910b06f4b 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_pay_term.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_pay_term.xml @@ -17,7 +17,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_pay_term_ecotax.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_pay_term_ecotax.xml index 638bedf87ba..cbb6e0515bb 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_pay_term_ecotax.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_pay_term_ecotax.xml @@ -17,7 +17,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/nlcius_out_invoice.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/nlcius_out_invoice.xml index 1fbb5a4ec10..2d3b24d0c02 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/nlcius_out_invoice.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/nlcius_out_invoice.xml @@ -14,7 +14,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/nlcius_out_refund.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/nlcius_out_refund.xml index 0d56dba317b..33fa0209c85 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/nlcius_out_refund.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/nlcius_out_refund.xml @@ -18,7 +18,6 @@ ___ignore___ - 381 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/xrechnung_ubl_out_invoice.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/xrechnung_ubl_out_invoice.xml index 8bec813aece..dedfc774bbc 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/xrechnung_ubl_out_invoice.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/xrechnung_ubl_out_invoice.xml @@ -14,7 +14,6 @@ ___ignore___ - 380 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/xrechnung_ubl_out_refund.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/xrechnung_ubl_out_refund.xml index e439850bcd5..fdac440ea49 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/xrechnung_ubl_out_refund.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/xrechnung_ubl_out_refund.xml @@ -13,7 +13,6 @@ ___ignore___ - 381 ___ignore___ diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_peppol-bis-invoice-3_doc/bis3_allowance.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_peppol-bis-invoice-3_doc/bis3_allowance.xml index a7e137d265f..5dfd549b583 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_peppol-bis-invoice-3_doc/bis3_allowance.xml +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_peppol-bis-invoice-3_doc/bis3_allowance.xml @@ -23,7 +23,6 @@ DR35141 - 130 ts12345 diff --git a/addons/l10n_dk_oioubl/models/account_edi_xml_oioubl_201.py b/addons/l10n_dk_oioubl/models/account_edi_xml_oioubl_201.py index 8a8b17ce14d..2dfc801fdf7 100644 --- a/addons/l10n_dk_oioubl/models/account_edi_xml_oioubl_201.py +++ b/addons/l10n_dk_oioubl/models/account_edi_xml_oioubl_201.py @@ -240,6 +240,7 @@ class AccountEdiXmlOIOUBL201(models.AbstractModel): # EXTENDS 'account_edi_ubl_cii # http://www.datypic.com/sc/ubl20/e-cbc_DocumentTypeCode.html vals = super()._get_document_type_code_vals(invoice, invoice_data) + vals['value'] = "380" if invoice.move_type == 'out_invoice' else "381" vals['attrs']['listAgencyID'] = "6" vals['attrs']['listID'] = "UN/ECE 1001" return vals diff --git a/addons/l10n_ro_edi/models/account_edi_xml_ubl_ciusro.py b/addons/l10n_ro_edi/models/account_edi_xml_ubl_ciusro.py index 097b441df79..a04aedc026b 100644 --- a/addons/l10n_ro_edi/models/account_edi_xml_ubl_ciusro.py +++ b/addons/l10n_ro_edi/models/account_edi_xml_ubl_ciusro.py @@ -72,6 +72,13 @@ class AccountEdiXmlUBLRO(models.AbstractModel): return vals + def _get_document_type_code_vals(self, invoice, invoice_data): + # EXTENDS 'account_edi_ubl_cii + # http://www.datypic.com/sc/ubl20/e-cbc_DocumentTypeCode.html + vals = super()._get_document_type_code_vals(invoice, invoice_data) + vals['value'] = "380" if invoice.move_type == 'out_invoice' else "381" + return vals + def _export_invoice_constraints(self, invoice, vals): # EXTENDS 'account_edi_ubl_cii' constraints = super()._export_invoice_constraints(invoice, vals)