bank-payment/account_banking_mandate_contact/models/res_partner.py

22 lines
718 B
Python
Raw Permalink Normal View History

2023-05-19 08:19:51 +00:00
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from flectra import fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
contact_mandate_id = fields.Many2one(
comodel_name="account.banking.mandate",
string="Contact Mandate",
)
def _compute_valid_mandate_id(self):
procesed_partners = self.browse()
for partner in self:
if partner.contact_mandate_id.state == "valid":
partner.valid_mandate_id = partner.contact_mandate_id
procesed_partners |= partner
return super(ResPartner, self - procesed_partners)._compute_valid_mandate_id()