Skip to content

Commit

Permalink
[FIX] use float_compare to compare floats
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierrick Brun committed Mar 6, 2023
1 parent bfd1971 commit 4fbf636
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pos_payment_change/wizards/pos_payment_change_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 4fbf636

Please sign in to comment.