Skip to content

Commit

Permalink
Merge pull request #1 from akretion/16.0-mig-pos_payment_change
Browse files Browse the repository at this point in the history
[FIX] use float_compare to compare floats
  • Loading branch information
julenfl authored Mar 16, 2023
2 parents bfd1971 + 4fbf636 commit 02ba9cb
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 02ba9cb

Please sign in to comment.