From 4fbf6365852886c82dab070df6a7fbe12dcac8a5 Mon Sep 17 00:00:00 2001 From: Pierrick Brun Date: Mon, 6 Mar 2023 13:46:19 +0100 Subject: [PATCH] [FIX] use float_compare to compare floats --- .../wizards/pos_payment_change_wizard.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pos_payment_change/wizards/pos_payment_change_wizard.py b/pos_payment_change/wizards/pos_payment_change_wizard.py index d8f34fdcd8..646176b1ec 100644 --- a/pos_payment_change/wizards/pos_payment_change_wizard.py +++ b/pos_payment_change/wizards/pos_payment_change_wizard.py @@ -4,6 +4,7 @@ from odoo import _, api, fields, models from odoo.exceptions import UserError +from odoo.tools import float_compare class PosPaymentChangeWizard(models.TransientModel): @@ -62,7 +63,14 @@ def button_change_payment(self): # Check if the total is correct total = sum(self.mapped("new_line_ids.amount")) - if total != self.amount_total: + if ( + float_compare( + total, + self.amount_total, + precision_rounding=self.order_id.currency_id.rounding, + ) + != 0 + ): raise UserError( _( "Differences between the two values for the POS"