From 60f54f2516bf2bdc870b72c2dd96d24c3458f076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roc=C3=ADo=20Vega?= Date: Fri, 4 Apr 2025 11:30:58 -0300 Subject: [PATCH] [FIX] account_invoice_tax: avoid including amount_currency when not needed Fixed an issue in '_get_amount_updated_values' where 'amount_currency' was included in the dictionary even when unnecessary, causing errors when 'amount_company_currency' was set to 'None'. Now, 'amount_currency' is only added if the move's currency differs from the company currency and 'self.amount' is set. This prevents operations involving 'None' values, avoiding errors when processing the data. Reported error: TypeError: unsupported operand type(s) for -: 'float' and 'NoneType' --- account_invoice_tax/wizards/account_invoice_tax.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/account_invoice_tax/wizards/account_invoice_tax.py b/account_invoice_tax/wizards/account_invoice_tax.py index aac0a08f..c31cd403 100644 --- a/account_invoice_tax/wizards/account_invoice_tax.py +++ b/account_invoice_tax/wizards/account_invoice_tax.py @@ -130,13 +130,17 @@ def _get_amount_updated_values(self): company_currency = self.invoice_tax_id.move_id.company_currency_id not_company_currency = move_currency and move_currency != company_currency - return { - "amount_currency": self.amount if not_company_currency else None, + values = { "debit": debit_cc if not_company_currency else debit, "credit": credit_cc if not_company_currency else credit, "balance": (self.amount_company_currency if not_company_currency else self.amount) * (1 if debit else -1), } + if not_company_currency and self.amount: + values["amount_currency"] = self.amount + + return values + def _compute_amount_company_currency(self): for line in self: taxes = line.invoice_tax_id.move_id.tax_totals["subtotals"][0]["tax_groups"]