Skip to content
Snippets Groups Projects
Commit a7034b75 authored by Anh Thao Pham (pta)'s avatar Anh Thao Pham (pta)
Browse files

[FIX] payment: use currency precision when comparing amounts in Payment Link wizard


In Sales, in Payment Link generation wizard, when entering manually the total of the quotation
as Amount, it can happen that the Validation Error asking to set an Amount smaller than the total
is triggered.

opw-2287794

closes odoo/odoo#54278

Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 966c6520
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ from werkzeug import urls
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
from odoo.tools import ustr, consteq
from odoo.tools import ustr, consteq, float_compare
class PaymentLinkWizard(models.TransientModel):
......@@ -46,7 +46,7 @@ class PaymentLinkWizard(models.TransientModel):
@api.onchange('amount', 'description')
def _onchange_amount(self):
if self.amount_max < self.amount:
if float_compare(self.amount_max, self.amount, precision_rounding=self.currency_id.rounding or 0.01) == -1:
raise ValidationError(_("Please set an amount smaller than %s.") % (self.amount_max))
if self.amount <= 0:
raise ValidationError(_("The value of the payment amount must be positive."))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment