changeset 9289363b33bd in modules/sale_promotion:default
details:
https://hg.tryton.org/modules/sale_promotion?cmd=changeset;node=9289363b33bd
description:
Add round_price
We add a common method to round prices that are stored using the price
digits.
It is useless to use the digits from the field because it can not be
changed in
any other way than by configuration.
issue9146
review299521002
diffstat:
sale.py | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diffs (22 lines):
diff -r 1cf36ff0c3b8 -r 9289363b33bd sale.py
--- a/sale.py Thu Mar 19 19:12:18 2020 +0100
+++ b/sale.py Thu Apr 23 21:44:00 2020 +0200
@@ -13,7 +13,7 @@
from trytond.transaction import Transaction
from trytond.tools import decistmt
-from trytond.modules.product import price_digits
+from trytond.modules.product import price_digits, round_price
from .exceptions import FormulaError
@@ -248,8 +248,7 @@
# Apply promotion only if all unit prices decrease
if all(l.unit_price >= p for l, p in new_prices.items()):
for line, unit_price in new_prices.items():
- line.unit_price = unit_price.quantize(
- Decimal(1) / 10 ** line.__class__.unit_price.digits[1])
+ line.unit_price = round_price(unit_price)
line.promotion = self
sale.lines = sale.lines # Trigger the change