Skip to content

Commit

Permalink
[FIX] l10n_ar_ux: Prevent pay with same check more than one time in t…
Browse files Browse the repository at this point in the history
…he same payment group.

Ticket: 32944
  • Loading branch information
pablohmontenegro committed Aug 11, 2023
1 parent e1e3070 commit daff34e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions l10n_ar_ux/models/account_payment.py
@@ -1,4 +1,5 @@
from odoo import fields, models, api
from odoo.exceptions import UserError


class AccountPayment(models.Model):
Expand Down Expand Up @@ -38,3 +39,9 @@ def _compute_payment_method_description(self):
name = "%s: %s" % (rec.payment_method_line_id.display_name, checks_desc)
rec.payment_method_description = name
return super(AccountPayment, (self - check_payments))._compute_payment_method_description()

@api.constrains('l10n_latam_check_id')
def pay_with_same_check_repeatedly(self):
""" Prevent pay with same check more than one time in the same payment group. """
if len(self.payment_group_id.payment_ids.filtered('l10n_latam_check_id.payment_method_description')) != len(self.payment_group_id.payment_ids.mapped('l10n_latam_check_id.payment_method_description')):
raise UserError("There are two or more payment lines with the same check.")

0 comments on commit daff34e

Please sign in to comment.