From 1b8155aba51818ee7436df4a4abe251d2f729b56 Mon Sep 17 00:00:00 2001 From: "Paolo (pgi)" Date: Mon, 25 Jul 2022 15:46:25 +0000 Subject: [PATCH] [FIX] l10n_it_edi_*: ImportoTotaleDocumento must include ReverseCharge taxes In the XML, on the field holds the untaxed amount but it should have the taxed amount. The field inside the xml correctly takes the total amount of the invoice, but on the invoice in Odoo when using a RC tax, the tax amount is 0 in Odoo, so the total amount will be as it is untaxed on the XML. That's because the repartition lines are +100%/-100% distributed, but in the self-invoice they must be exported as +100%, so we re-add them to the total. Task link: https://www.odoo.com/web#id=2936967&model=project.task opw-2936967 closes odoo/odoo#97147 X-original-commit: 83e41d6f1adc30e24cda95c5f4ab2a875e1bcaa0 Signed-off-by: Josse Colpaert --- addons/l10n_it_edi/data/invoice_it_template.xml | 2 +- addons/l10n_it_edi/models/account_invoice.py | 7 +++++++ .../tests/expected_xmls/reverse_charge_bill.xml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml index 11257cd3dce..3ec25dc45f5 100644 --- a/addons/l10n_it_edi/data/invoice_it_template.xml +++ b/addons/l10n_it_edi/data/invoice_it_template.xml @@ -132,7 +132,7 @@ SI - + diff --git a/addons/l10n_it_edi/models/account_invoice.py b/addons/l10n_it_edi/models/account_invoice.py index b3ba9de9fe8..94493f03639 100644 --- a/addons/l10n_it_edi/models/account_invoice.py +++ b/addons/l10n_it_edi/models/account_invoice.py @@ -178,6 +178,12 @@ class AccountMove(models.Model): or (partner.country_id.code == 'IT' and '0000000') or 'XXXXXXX') + # Self-invoices are technically -100%/+100% repartitioned + # but functionally need to be exported as 100% + document_total = self.amount_total + if is_self_invoice: + document_total += sum([v['tax_amount_currency'] for k, v in tax_details['tax_details'].items()]) + # Create file content. template_values = { 'record': self, @@ -191,6 +197,7 @@ class AccountMove(models.Model): 'seller': seller, 'seller_partner': company.partner_id if not is_self_invoice else partner, 'currency': self.currency_id or self.company_currency_id, + 'document_total': document_total, 'representative': company.l10n_it_tax_representative_partner_id, 'codice_destinatario': codice_destinatario, 'regime_fiscale': company.l10n_it_tax_system if not is_self_invoice else 'RF01', diff --git a/addons/l10n_it_edi_sdicoop/tests/expected_xmls/reverse_charge_bill.xml b/addons/l10n_it_edi_sdicoop/tests/expected_xmls/reverse_charge_bill.xml index 44f5177021c..9b5fc4e1c28 100644 --- a/addons/l10n_it_edi_sdicoop/tests/expected_xmls/reverse_charge_bill.xml +++ b/addons/l10n_it_edi_sdicoop/tests/expected_xmls/reverse_charge_bill.xml @@ -54,7 +54,7 @@ EUR 2022-03-24 BILL/2022/03/0001 - 1600.80 + 1808.91