[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#54309

X-original-commit: a7034b75383f23f309d97a86cbde7d9f8176ed6d
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Anh Thao Pham (pta)
2020-07-10 09:41:08 +00:00
parent 878a92b528
commit cc8c036f87
@@ -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."))