From 709832c16b54aaef546e48e4db0b78bfd077e44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 2 Mar 2026 15:23:13 +0100 Subject: [PATCH] Use currency rounding when currency has no cash rounding set Closes #14638 --- modules/account_cash_rounding/currency.py | 6 +++++- .../scenario_account_cash_rounding_alternate_currency.rst | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/account_cash_rounding/currency.py b/modules/account_cash_rounding/currency.py index c224ca0a28..77d24a8ada 100644 --- a/modules/account_cash_rounding/currency.py +++ b/modules/account_cash_rounding/currency.py @@ -15,4 +15,8 @@ class Currency(metaclass=PoolMeta): digits=(None, Eval('digits', None))) def cash_round(self, amount, rounding=ROUND_HALF_EVEN): - return self._round(amount, self.cash_rounding, rounding) + if self.cash_rounding is not None: + factor = self.cash_rounding + else: + factor = self.rounding + return self._round(amount, factor, rounding) diff --git a/modules/account_cash_rounding/tests/scenario_account_cash_rounding_alternate_currency.rst b/modules/account_cash_rounding/tests/scenario_account_cash_rounding_alternate_currency.rst index 9a0341492e..4edfb9ee47 100644 --- a/modules/account_cash_rounding/tests/scenario_account_cash_rounding_alternate_currency.rst +++ b/modules/account_cash_rounding/tests/scenario_account_cash_rounding_alternate_currency.rst @@ -105,6 +105,6 @@ Post invoice:: >>> line_to_pay, = invoice.lines_to_pay >>> line_to_pay.debit, line_to_pay.credit - (Decimal('21.02'), Decimal('0')) + (Decimal('21.02'), Decimal('0.00')) >>> line_to_pay.amount_second_currency Decimal('42.05')