From 66da6f3312f539d4b2450bd7f302cbeb11d535e5 Mon Sep 17 00:00:00 2001 From: Bejaoui Souheil Date: Mon, 15 Jul 2024 13:25:16 +0200 Subject: [PATCH] [IMP] l10n_be_iso20022_pain: check BBA structured communication on payment line check BBA structured communication on payment line only if the journal invoice reference model is "be" Co-authored-by: Thomas Binsfeld (ACSONE) --- l10n_be_iso20022_pain/models/account_payment_line.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/l10n_be_iso20022_pain/models/account_payment_line.py b/l10n_be_iso20022_pain/models/account_payment_line.py index e96ab90c..3bba5429 100644 --- a/l10n_be_iso20022_pain/models/account_payment_line.py +++ b/l10n_be_iso20022_pain/models/account_payment_line.py @@ -10,10 +10,12 @@ class AccountPaymentLine(models.Model): _inherit = "account.payment.line" - @api.constrains("communication", "communication_type") + @api.constrains("order_id", "communication", "communication_type") def _check_communication(self): for rec in self: - if rec.communication_type == "structured" and not check_bbacomm( - rec.communication + if ( + rec.order_id.journal_id.invoice_reference_model == "be" + and rec.communication_type == "structured" + and not check_bbacomm(rec.communication ): raise ValidationError(_("Invalid BBA Structured Communication !"))