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 Sep 1, 2023
1 parent 7191955 commit 8027336
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions l10n_ar_ux/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from odoo import fields, models, api
from odoo.exceptions import UserError


class AccountPayment(models.Model):
Expand Down Expand Up @@ -52,3 +53,9 @@ def _compute_l10n_latam_check_bank_id(self):
for rec in new_third_party_checks:
rec.l10n_latam_check_bank_id = rec.partner_id.bank_ids[:1].bank_id or rec.l10n_latam_check_bank_id
(self - new_third_party_checks).l10n_latam_check_bank_id = False

@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 8027336

Please sign in to comment.