[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.
This commit is contained in:
Laurent Smet
2019-08-21 07:03:14 +00:00
parent f26de445e5
commit 1ca5c01b36
+1 -1
View File
@@ -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)