From 3c31bceca4b409f06df37aa2fabcb985b87e7ca2 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Tue, 23 Feb 2021 10:34:52 +0000 Subject: [PATCH] [FIX] l10n_it_edi: generate xml for invoices with 0% tax only Have an invoice with single line and 0% tax on it As the tax has 0 amount, no related moves are created, the e-invoice export will fail the formal compliance check as it is missing a section opw-2461496 closes odoo/odoo#66960 X-original-commit: 71cc7212b1c1abad5d37e29f3a1f33f6e6cd2a81 Signed-off-by: agr-odoo --- addons/l10n_it_edi/data/invoice_it_template.xml | 12 +++++++++++- addons/l10n_it_edi/models/account_invoice.py | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml index cfb2833e556..3713bd66e92 100644 --- a/addons/l10n_it_edi/data/invoice_it_template.xml +++ b/addons/l10n_it_edi/data/invoice_it_template.xml @@ -172,7 +172,17 @@ - + + + + + + + + + + + diff --git a/addons/l10n_it_edi/models/account_invoice.py b/addons/l10n_it_edi/models/account_invoice.py index 549bce2c4d2..da3098852ab 100644 --- a/addons/l10n_it_edi/models/account_invoice.py +++ b/addons/l10n_it_edi/models/account_invoice.py @@ -223,6 +223,13 @@ class AccountMove(models.Model): pdf = base64.b64encode(pdf) pdf_name = re.sub(r'\W+', '', self.name) + '.pdf' + # tax map for 0% taxes which have no tax_line_id + tax_map = dict() + for line in self.line_ids: + for tax in line.tax_ids: + if tax.amount == 0.0: + tax_map[tax] = tax_map.get(tax, 0.0) + line.price_subtotal + # Create file content. template_values = { 'record': self, @@ -240,6 +247,7 @@ class AccountMove(models.Model): 'document_type': document_type, 'pdf': pdf, 'pdf_name': pdf_name, + 'tax_map': tax_map, } content = self.env.ref('l10n_it_edi.account_invoice_it_FatturaPA_export')._render(template_values) return content