diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 91a95ba359d..1d1d50cfc01 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -615,7 +615,16 @@ class AccountTax(models.Model): if self.amount_type == 'fixed': # 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 + # Amount is the fixed price for the tax, it can be negative + # Base amount included the sign of the quantity and the sign of the unit price and when + # a product is returned, it can be done either by changing the sign of quantity or by changing the + # sign of the price unit. + # When the price unit is equal to 0, the sign of the quantity is absorbed in base_amount then + # a "else" case is needed. + if base_amount: + return math.copysign(quantity, base_amount) * self.amount + else: + return quantity * 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: