Allow cash rounding with opposite method

This commit is contained in:
Cédric Krier
2026-03-02 15:21:27 +01:00
parent e4cb6234a1
commit a77f01aff0
3 changed files with 14 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
* Allow cash rounding with opposite method
* Add support for Python 3.14
* Remove support for Python 3.9
+4 -1
View File
@@ -3,6 +3,7 @@
from decimal import ROUND_HALF_EVEN
from trytond.model import fields
from trytond.modules.currency import ROUNDING_OPPOSITES
from trytond.pool import PoolMeta
from trytond.pyson import Eval
@@ -14,7 +15,9 @@ class Currency(metaclass=PoolMeta):
"Cash Rounding Factor",
digits=(None, Eval('digits', None)))
def cash_round(self, amount, rounding=ROUND_HALF_EVEN):
def cash_round(self, amount, rounding=ROUND_HALF_EVEN, opposite=False):
if opposite:
rounding = ROUNDING_OPPOSITES[rounding]
if self.cash_rounding is not None:
factor = self.cash_rounding
else:
+9
View File
@@ -1,2 +1,11 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
__all__ = ['ROUNDING_OPPOSITES']
def __getattr__(name):
if name == 'ROUNDING_OPPOSITES':
from .currency import ROUNDING_OPPOSITES
return ROUNDING_OPPOSITES
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")