From 2cfdf25d7bca060b94778107b010d81ff6bb228b Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Wed, 29 Jan 2025 10:01:05 +0100 Subject: [PATCH] add price_digits() to mixin.py --- mixin.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mixin.py b/mixin.py index b5587af..a81ca70 100644 --- a/mixin.py +++ b/mixin.py @@ -10,7 +10,15 @@ from trytond.exceptions import UserError from trytond.modules.tryton6_backport.i18n import gettext from cached_property import cached_property from trytond.pool import Pool -from trytond.modules.product import round_price +from trytond.modules.product import price_digits + + +def round_price(value, rounding=None): + "Round price using the price digits" + if isinstance(value, int): + return Decimal(value) + return value.quantize( + Decimal(1) / 10 ** price_digits[1], rounding=rounding) class EdocumentMixin(object):