From 6cf275cc6b73a7d817a7db023ca3206c09527d62 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 18 Jul 2016 11:43:18 +0200 Subject: [PATCH] =?UTF-8?q?[FIX]=C2=A0account:=20Computation=20of=20a=20fi?= =?UTF-8?q?xed=20amount=20tax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- addons/account/models/account.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index ff6ee0bb1c7..7652895dca0 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -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: