add price_digits() to mixin.py
This commit is contained in:
parent
f944b9019c
commit
2cfdf25d7b
1 changed files with 9 additions and 1 deletions
10
mixin.py
10
mixin.py
|
@ -10,7 +10,15 @@ from trytond.exceptions import UserError
|
||||||
from trytond.modules.tryton6_backport.i18n import gettext
|
from trytond.modules.tryton6_backport.i18n import gettext
|
||||||
from cached_property import cached_property
|
from cached_property import cached_property
|
||||||
from trytond.pool import Pool
|
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):
|
class EdocumentMixin(object):
|
||||||
|
|
Loading…
Reference in a new issue