From 75e583328fa30454a853f1f1fc65f77c893c45e6 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Wed, 4 Dec 2024 16:37:06 +0100 Subject: [PATCH] account_invoice_ubl: fix tax In case of tax exempt invoice where lines have a tax without repartition lines, declare tax based on the tax of the line --- account_invoice_ubl/models/account_move.py | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/account_invoice_ubl/models/account_move.py b/account_invoice_ubl/models/account_move.py index 38e91edae7..39b115a236 100644 --- a/account_invoice_ubl/models/account_move.py +++ b/account_invoice_ubl/models/account_move.py @@ -327,18 +327,25 @@ def _ubl_add_tax_total(self, xml_root, ns, version="2.1"): cur_name = self.currency_id.name prec = self.currency_id.decimal_places - # There are as many tax line as there are repartition lines tax_lines = {} for tline in self.line_ids: - if not tline.tax_line_id: - continue - tax_lines.setdefault( - tline.tax_line_id, - {"base": 0.0, "amount": 0.0}, - ) - tax_lines[tline.tax_line_id]["base"] += tline.tax_base_amount - sign = 1 if tline.is_refund else -1 - tax_lines[tline.tax_line_id]["amount"] += sign * tline.balance + if tline.tax_line_id: + # There are as many tax line as there are repartition lines + tax_lines.setdefault( + tline.tax_line_id, + {"base": 0.0, "amount": 0.0}, + ) + tax_lines[tline.tax_line_id]["base"] += tline.tax_base_amount + sign = 1 if tline.is_refund else -1 + tax_lines[tline.tax_line_id]["amount"] += sign * tline.balance + elif tline.tax_ids: + # In case there are no repartition lines + for tax in tline.tax_ids: + tax_lines.setdefault( + tax, + {"base": 0.0, "amount": 0.0}, + ) + tax_lines[tax]["base"] += tline.balance exempt = 0.0 exempt_taxes = self.line_ids.tax_line_id.browse()