details: https://code.tryton.org/tryton/commit/eb1ceb80cca8
branch: default
user: Cédric Krier <[email protected]>
date: Mon Mar 02 15:21:27 2026 +0100
description:
Allow cash rounding with opposite method
diffstat:
modules/account_cash_rounding/CHANGELOG | 1 +
modules/account_cash_rounding/currency.py | 5 ++++-
modules/currency/__init__.py | 9 +++++++++
3 files changed, 14 insertions(+), 1 deletions(-)
diffs (45 lines):
diff -r 8fa10a4e241d -r eb1ceb80cca8 modules/account_cash_rounding/CHANGELOG
--- a/modules/account_cash_rounding/CHANGELOG Thu Feb 19 09:54:48 2026 +0100
+++ b/modules/account_cash_rounding/CHANGELOG Mon Mar 02 15:21:27 2026 +0100
@@ -1,3 +1,4 @@
+* Allow cash rounding with opposite method
* Add support for Python 3.14
* Remove support for Python 3.9
diff -r 8fa10a4e241d -r eb1ceb80cca8 modules/account_cash_rounding/currency.py
--- a/modules/account_cash_rounding/currency.py Thu Feb 19 09:54:48 2026 +0100
+++ b/modules/account_cash_rounding/currency.py Mon Mar 02 15:21:27 2026 +0100
@@ -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 @@
"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:
diff -r 8fa10a4e241d -r eb1ceb80cca8 modules/currency/__init__.py
--- a/modules/currency/__init__.py Thu Feb 19 09:54:48 2026 +0100
+++ b/modules/currency/__init__.py Mon Mar 02 15:21:27 2026 +0100
@@ -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}")