mirror of
https://gitlab.com/flectra-community/bank-payment.git
synced 2024-11-22 13:42:07 +00:00
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
# Copyright 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
|
|
# Copyright 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
|
# Copyright 2015-16 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
|
|
|
from flectra import api, fields, models, _
|
|
from flectra.exceptions import ValidationError
|
|
|
|
|
|
class BankPaymentLine(models.Model):
|
|
_inherit = 'bank.payment.line'
|
|
|
|
mandate_id = fields.Many2one(
|
|
comodel_name='account.banking.mandate', string='Direct Debit Mandate',
|
|
related='payment_line_ids.mandate_id')
|
|
|
|
@api.model
|
|
def same_fields_payment_line_and_bank_payment_line(self):
|
|
res = super(BankPaymentLine, self).\
|
|
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))
|