From ffbfab098d44fa75f4451b556130ceb6cb8ec40a Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Thu, 6 Jul 2023 14:33:55 +0000 Subject: [PATCH] [FIX] account: cash rounding float check Fixup of 5cb044dd8a2385c9a3c09520ed97eb4faa39216d We should use float_compare when working with float amounts as the standard == may give wrong results opw-3389449 closes odoo/odoo#127684 X-original-commit: 91f970fdfd8136e303b7052d690d8997f0278f24 Signed-off-by: John Laterre (jol) --- addons/account/models/account_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index e9e2f1611c8..2eed2a8e8d6 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2002,8 +2002,8 @@ class AccountMove(models.Model): # No update needed if existing_cash_rounding_line \ - and existing_cash_rounding_line.balance == diff_balance \ - and existing_cash_rounding_line.amount_currency == diff_amount_currency: + and float_compare(existing_cash_rounding_line.balance, diff_balance, precision_rounding=self.currency_id.rounding) == 0 \ + and float_compare(existing_cash_rounding_line.amount_currency, diff_amount_currency, precision_rounding=self.currency_id.rounding) == 0: return _apply_cash_rounding(self, diff_balance, diff_amount_currency, existing_cash_rounding_line)