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

 subscription.py |  6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r 4cdfa6503f87 -r 7ced341ede12 subscription.py
--- a/subscription.py   Mon Apr 13 12:21:55 2020 +0200
+++ b/subscription.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 datetime
-from decimal import Decimal
 from itertools import groupby
 
 from sql import operators, Literal, Null
@@ -20,7 +19,7 @@
 
 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 InvoiceError
 
 
@@ -636,8 +635,7 @@
             self.unit_price = Product.get_sale_price(
                 [product], self.quantity or 0)[product.id]
             if self.unit_price:
-                self.unit_price = self.unit_price.quantize(
-                    Decimal(1) / 10 ** self.__class__.unit_price.digits[1])
+                self.unit_price = round_price(self.unit_price)
 
         self.consumption_recurrence = self.service.consumption_recurrence
         self.consumption_delay = self.service.consumption_delay

Reply via email to