From 1ca5c01b36ef29406abb860fd2e638a34db22052 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Wed, 21 Aug 2019 07:03:14 +0000 Subject: [PATCH] [FIX] account: Fix price_unit sign in taxes computation Since the base in compute_all could be negative but is signed to perform the computation, the price_unit should follow the same logic and be signed when evaluating a python tax. Before this commit, the price_unit was equivalent to the base line balance and then, was negative in case of a customer invoice. E.g. For an out_invoice of 100, the price_unit is 100 but the balance is -100 for the base line. Then, the computation is done using a base of 100 but having a sign of -1. However, when evaluating a python tax dependent of the price_unit (here the balance), the price_unit was negative and then, the tax amount will have a wrong sign at the end. --- addons/account/models/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 5cd647e5648..f55eb751b20 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -1400,7 +1400,7 @@ class AccountTax(models.Model): cumulated_tax_included_amount = 0 else: tax_amount = tax.with_context(force_price_include=False)._compute_amount( - base, price_unit, quantity, product, partner) + base, sign * price_unit, quantity, product, partner) # Round the tax_amount tax_amount = round(tax_amount, prec)