changeset e68216124bb0 in modules/sale:default
details: https://hg.tryton.org/modules/sale?cmd=changeset;node=e68216124bb0
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 6cbeb76e5c32 -r e68216124bb0 sale.py
--- a/sale.py   Tue Apr 14 09:27:53 2020 +0200
+++ b/sale.py   Thu Apr 23 21:44:00 2020 +0200
@@ -22,7 +22,7 @@
 from trytond.modules.account_product.exceptions import AccountError
 from trytond.modules.company.model import (
     employee_field, set_employee, reset_employee)
-from trytond.modules.product import price_digits
+from trytond.modules.product import price_digits, round_price
 
 from .exceptions import (
     SaleValidationError, SaleQuotationError, PartyLocationError)
@@ -1273,8 +1273,7 @@
             unit_price = Product.get_sale_price([self.product],
                 self.quantity or 0)[self.product.id]
             if unit_price:
-                unit_price = unit_price.quantize(
-                    Decimal(1) / 10 ** self.__class__.unit_price.digits[1])
+                unit_price = round_price(unit_price)
             return unit_price
 
     @fields.depends('product')

Reply via email to