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()