[FIX] account: Computation of a fixed amount tax

When an order with a fixed amount tax was returned the sign of the tax
was wrong because amount_base was negative and quantity was negative too,
then the tax was positive due to math.copysign(self.amount, base_amount) * abs(quantity)

The sign of the base amount already takes into account the the sign
of the quantity.

opw:682407
This commit is contained in:
Goffin Simon
2016-07-18 12:51:16 +02:00
parent fbca56111b
commit 6cf275cc6b
+3 -1
View File
@@ -613,7 +613,9 @@ class AccountTax(models.Model):
"""
self.ensure_one()
if self.amount_type == 'fixed':
return math.copysign(self.amount, base_amount) * abs(quantity)
# Use copysign to take into account the sign of the base amount which includes the sign
# of the quantity and the sign of the price_unit
return math.copysign(quantity, base_amount) * self.amount
if (self.amount_type == 'percent' and not self.price_include) or (self.amount_type == 'division' and self.price_include):
return base_amount * self.amount / 100
if self.amount_type == 'percent' and self.price_include: