diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py index a002d6be9a8..b4dfb056a0a 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py @@ -195,8 +195,6 @@ class AccountEdiXmlUBLBIS3(models.AbstractModel): for vals in vals_list: vals.pop('name') - # [UBL-CR-601]-A UBL invoice should not include the InvoiceLine Item ClassifiedTaxCategory TaxExemptionReason - #vals.pop('tax_exemption_reason') return vals_list @@ -212,6 +210,17 @@ class AccountEdiXmlUBLBIS3(models.AbstractModel): return vals_list + def _get_invoice_line_item_vals(self, line, taxes_vals): + # EXTENDS account.edi.xml.ubl_21 + line_item_vals = super()._get_invoice_line_item_vals(line, taxes_vals) + + for val in line_item_vals['classified_tax_category_vals']: + # [UBL-CR-601] TaxExemptionReason must not appear in InvoiceLine Item ClassifiedTaxCategory + # [BR-E-10] TaxExemptionReason must only appear in TaxTotal TaxSubtotal TaxCategory + val.pop('tax_exemption_reason') + + return line_item_vals + def _get_invoice_line_allowance_vals_list(self, line, tax_values_list=None): # EXTENDS account.edi.xml.ubl_21 vals_list = super()._get_invoice_line_allowance_vals_list(line, tax_values_list=tax_values_list) diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_tax_exempt.xml b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_tax_exempt.xml new file mode 100644 index 00000000000..3d1d8d03453 --- /dev/null +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_files/from_odoo/bis3_out_invoice_tax_exempt.xml @@ -0,0 +1,142 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + ___ignore___ + 2017-01-01 + 2017-02-28 + 380 + test narration + USD + ref_partner_2 + + ___ignore___ + + + ___ignore___ + + ___ignore___ + + + + + 0202239951 + + partner_1 + + + Chaussée de Namur 40 + Ramillies + 1367 + + BE + + + + BE0202239951 + + VAT + + + + partner_1 + BE0202239951 + + + partner_1 + + + + + + 0477472701 + + partner_2 + + + Rue des Bourlottes 9 + Ramillies + 1367 + + BE + + + + BE0477472701 + + VAT + + + + partner_2 + BE0477472701 + + + partner_2 + + + + + + + Rue des Bourlottes 9 + Ramillies + 1367 + + BE + + + + + + 30 + ___ignore___ + + BE15001559627230 + + + + Payment terms: 30% Advance End of Following Month + + + 0.00 + + 990.00 + 0.00 + + E + 0.0 + Articles 226 items 11 to 15 Directive 2006/112/EN + + VAT + + + + + + 990.00 + 990.00 + 990.00 + 0.00 + 990.00 + + + 1 + 1.0 + 990.00 + + product_a + product_a + + E + 0.0 + + VAT + + + + + 990.0 + + + diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_xml_ubl_be.py b/addons/l10n_account_edi_ubl_cii_tests/tests/test_xml_ubl_be.py index 37ae1837e05..10a76159e8b 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_xml_ubl_be.py +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_xml_ubl_be.py @@ -80,6 +80,14 @@ class TestUBLBE(TestUBLCommon, TestAccountMoveSendCommon): 'country_id': cls.env.ref('base.be').id, }) + cls.tax_0 = cls.env['account.tax'].create({ + 'name': 'tax_0', + 'amount_type': 'percent', + 'amount': 0, + 'type_tax_use': 'sale', + 'country_id': cls.env.ref('base.be').id, + }) + cls.env.company.invoice_is_ubl_cii = True cls.pay_term = cls.env['account.payment.term'].create({ @@ -504,6 +512,21 @@ class TestUBLBE(TestUBLCommon, TestAccountMoveSendCommon): price_amount = etree.fromstring(invoice.ubl_cii_xml_id.raw).find('.//{*}InvoiceLine/{*}Price/{*}PriceAmount') self.assertEqual(price_amount.text, '102.15') + def test_export_tax_exempt(self): + invoice = self._generate_move( + self.partner_1, + self.partner_2, + move_type='out_invoice', + invoice_line_ids=[ + { + 'product_id': self.product_a.id, + 'price_unit': 990.0, + 'tax_ids': [(6, 0, self.tax_0.ids)], + }, + ], + ) + self._assert_invoice_attachment(invoice.ubl_cii_xml_id, None, 'from_odoo/bis3_out_invoice_tax_exempt.xml') + #################################################### # Test import #################################################### @@ -677,12 +700,11 @@ class TestUBLBE(TestUBLCommon, TestAccountMoveSendCommon): def test_import_payment_terms(self): # The tax 21% from l10n_be is retrieved since it's a duplicate of self.tax_21 tax_21 = self.env.ref(f'account.{self.env.company.id}_attn_VAT-OUT-21-L') - tax_0 = self.env.ref(f'account.{self.env.company.id}_attn_VAT-OUT-00-L') self._assert_imported_invoice_from_file( subfolder='tests/test_files/from_odoo', filename='bis3_pay_term.xml', amount_total=3105.68, amount_tax=505.68, list_line_subtotals=[-4, -48, 52, 200, 2400], currency_id=self.currency_data['currency'].id, list_line_price_unit=[-4, -48, 52, 200, 2400], - list_line_discount=[0, 0, 0, 0, 0], list_line_taxes=[self.tax_6, tax_21, tax_0, self.tax_6, tax_21], + list_line_discount=[0, 0, 0, 0, 0], list_line_taxes=[self.tax_6, tax_21, self.tax_0, self.tax_6, tax_21], move_type='out_invoice', )