changeset c16b07d666f8 in modules/sale_point:default
details: 
https://hg.tryton.org/modules/sale_point?cmd=changeset&node=c16b07d666f8
description:
        Use round_price instead of quantize base on field digits
diffstat:

 product.py |  12 ++++--------
 sale.py    |  10 ++++------
 2 files changed, 8 insertions(+), 14 deletions(-)

diffs (59 lines):

diff -r f093b88df15e -r c16b07d666f8 product.py
--- a/product.py        Mon Oct 11 23:55:41 2021 +0200
+++ b/product.py        Thu Oct 14 16:33:03 2021 +0200
@@ -1,12 +1,10 @@
 # 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 trytond.pool import PoolMeta, Pool
 from trytond.model import ModelSQL, fields
 from trytond.pyson import Eval
 
-from trytond.modules.product import price_digits
+from trytond.modules.product import price_digits, round_price
 from trytond.modules.company.model import CompanyValueMixin
 
 
@@ -37,11 +35,9 @@
         Tax = pool.get('account.tax')
         if self.gross_price is None or not self.account_category:
             return
-        self.list_price = Tax.reverse_compute(
-            self.gross_price,
-            self.customer_taxes_used).quantize(
-                Decimal(1)
-                / 10 ** self.__class__.list_price.digits[1])
+        self.list_price = round_price(Tax.reverse_compute(
+                self.gross_price,
+                self.customer_taxes_used))
 
 
 class Product(metaclass=PoolMeta):
diff -r f093b88df15e -r c16b07d666f8 sale.py
--- a/sale.py   Mon Oct 11 23:55:41 2021 +0200
+++ b/sale.py   Thu Oct 14 16:33:03 2021 +0200
@@ -13,7 +13,7 @@
 from trytond.model.exceptions import AccessError
 from trytond.modules.account.tax import TaxableMixin
 from trytond.modules.currency.fields import Monetary
-from trytond.modules.product import price_digits
+from trytond.modules.product import price_digits, round_price
 from trytond.pool import Pool
 from trytond.pyson import Bool, Eval, Id, If
 from trytond.tools import grouped_slice, reduce_ids
@@ -536,11 +536,9 @@
             if (self.sale.point.tax_included
                     and self.product.gross_price is not None):
                 self.unit_gross_price = self.product.gross_price
-                self.unit_list_price = Tax.reverse_compute(
-                    self.unit_gross_price, self.taxes,
-                    date=self.sale.date).quantize(
-                        Decimal(1)
-                        / 10 ** self.__class__.unit_list_price.digits[1])
+                self.unit_list_price = round_price(Tax.reverse_compute(
+                        self.unit_gross_price, self.taxes,
+                        date=self.sale.date))
             else:
                 self.unit_list_price = self.product.list_price
                 taxes = Tax.compute(

Reply via email to