diff --git a/account_banking_mandate/models/bank_payment_line.py b/account_banking_mandate/models/bank_payment_line.py index b4be429cb..5c0a63371 100644 --- a/account_banking_mandate/models/bank_payment_line.py +++ b/account_banking_mandate/models/bank_payment_line.py @@ -3,8 +3,7 @@ # Copyright 2015-16 Akretion - Alexis de Lattre # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import api, fields, models, _ -from odoo.exceptions import ValidationError +from odoo import api, fields, models class BankPaymentLine(models.Model): @@ -20,13 +19,3 @@ class BankPaymentLine(models.Model): same_fields_payment_line_and_bank_payment_line() res.append('mandate_id') return res - - @api.constrains('mandate_id', 'company_id') - def _check_company_constrains(self): - for line in self: - if line.mandate_id.company_id and line.mandate_id.company_id != \ - line.company_id: - raise ValidationError(_( - "The bank payment line %s has a different company than " - "that of the linked mandate %s).") % - (line.name, line.mandate_id.display_name)) diff --git a/account_banking_mandate/tests/test_mandate.py b/account_banking_mandate/tests/test_mandate.py index 74d0b6dae..767bc025b 100644 --- a/account_banking_mandate/tests/test_mandate.py +++ b/account_banking_mandate/tests/test_mandate.py @@ -107,6 +107,7 @@ class TestMandate(TransactionCase): bank_account_2 = self.env['res.partner.bank'].create({ 'acc_number': '1234', 'company_id': self.company_2.id, + 'partner_id': self.company_2.partner_id.id, }) with self.assertRaises(ValidationError): mandate.partner_bank_id = bank_account_2 @@ -119,6 +120,7 @@ class TestMandate(TransactionCase): bank_account = self.env['res.partner.bank'].create({ 'acc_number': '1234', 'company_id': self.company_2.id, + 'partner_id': self.company_2.partner_id.id, }) with self.assertRaises(ValidationError): bank_account.mandate_ids += mandate diff --git a/account_banking_mandate/views/account_banking_mandate_view.xml b/account_banking_mandate/views/account_banking_mandate_view.xml index a68179564..64d7c087f 100644 --- a/account_banking_mandate/views/account_banking_mandate_view.xml +++ b/account_banking_mandate/views/account_banking_mandate_view.xml @@ -68,11 +68,20 @@ -