From bc2a79abc9dd41f1c010084ff657dd72443cd1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80ngel=20=C3=80lvarez?= Date: Thu, 21 Oct 2021 11:38:25 +0200 Subject: [PATCH] add rounding to price functions --- template.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/template.py b/template.py index a8e1ca1..e12d9c2 100644 --- a/template.py +++ b/template.py @@ -4,6 +4,8 @@ from trytond.model import fields from trytond.pyson import Eval, Bool, Not from trytond.pool import Pool, PoolMeta from decimal import Decimal +from trytond.modules.product import price_digits + __all__ = ['Template'] @@ -70,7 +72,7 @@ class Template(metaclass=PoolMeta): if self.use_info_unit and self.info_ratio and self.list_price: price = (self.list_price / Decimal(str(self.info_ratio))).quantize( _ROUND) - return price / Decimal(str(factor)) + return (price / Decimal(str(factor))).quantize(_ROUND) def get_unit_price(self, info_price, unit=None): price = _ZERO @@ -78,7 +80,8 @@ class Template(metaclass=PoolMeta): if self.use_info_unit: price = (info_price * Decimal(str(self.info_ratio))).quantize( _ROUND) - return price / Decimal(str(factor)) + return (price / Decimal(str(factor))).quantize( + Decimal('10')**-price_digits[1]) def get_info_unit_price(self, unit_price, unit=None): price = _ZERO