changeset fc537a2933c4 in modules/production_outsourcing:default
details: 
https://hg.tryton.org/modules/production_outsourcing?cmd=changeset;node=fc537a2933c4
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:

 production.py |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r bd0c64c4e6d9 -r fc537a2933c4 production.py
--- a/production.py     Thu Mar 19 19:06:49 2020 +0100
+++ b/production.py     Thu Apr 23 21:44:00 2020 +0200
@@ -1,7 +1,6 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 import hashlib
-from decimal import Decimal
 from itertools import groupby
 
 from trytond.i18n import gettext
@@ -9,6 +8,8 @@
 from trytond.pool import PoolMeta, Pool
 from trytond.pyson import Eval, Bool, If
 
+from trytond.modules.product import round_price
+
 from .exceptions import PurchaseWarning
 
 
@@ -123,8 +124,7 @@
                 cost += Currency.compute(
                     line.purchase.currency, line.amount,
                     self.company.currency, round=False)
-        digits = self.__class__.cost.digits
-        return cost.quantize(Decimal(str(10 ** -digits[1])))
+        return round_price(cost)
 
     @classmethod
     @ModelView.button

Reply via email to