diff options
| author | Goffin Simon <sig@odoo.com> | 2016-08-09 14:01:42 +0200 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2016-08-09 15:06:58 +0200 |
| commit | bb72dea98de4dae8f59e397f232a0636411d37ce (patch) | |
| tree | fab80d6b8e48d79574549e5ee99c143c9ea31041 | |
| parent | c79ba8f78531d87d1c4a82bfad0f8448cd01ee79 (diff) | |
[FIX] account: return of product with unit price = 0 and fixed tax
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
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.
opw:684459
| -rw-r--r-- | addons/account/models/account.py | 11 |
1 files changed, 10 insertions, 1 deletions
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: |
