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 !"))