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

 product.py |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r 002b70212fe9 -r d72dd8de77d7 product.py
--- a/product.py        Thu Mar 19 19:06:37 2020 +0100
+++ b/product.py        Thu Apr 23 21:44:00 2020 +0200
@@ -1,7 +1,5 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
-from decimal import Decimal
-
 from sql import Column, Literal, Window
 from sql.aggregate import Max
 from sql.conditionals import Coalesce
@@ -11,6 +9,8 @@
 from trytond.pool import Pool, PoolMeta
 from trytond.transaction import Transaction
 
+from trytond.modules.product import round_price
+
 
 def convert_from(table, tables):
     right, condition = tables[None]
@@ -48,8 +48,7 @@
                 ], limit=1, order=[('date', 'DESC')])
         if records:
             record, = records
-            return record.cost_price.quantize(
-                Decimal(str(10. ** -self.__class__.cost_price.digits[1])))
+            return round_price(record.cost_price)
 
 
 class CostPrice(metaclass=PoolMeta):

Reply via email to