From 9d7d8843c7d30438facef4881d3034bcd9b6832a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 23 Apr 2020 21:44:00 +0200 Subject: [PATCH] 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 --- production.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/production.py b/production.py index 3f1c85beed..de238be7d9 100644 --- a/production.py +++ b/production.py @@ -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.model import ModelView, Workflow, fields 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 @@ class Production(metaclass=PoolMeta): 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