|
@ -1,5 +1,6 @@ |
|
|
# Copyright 2019 Coop IT Easy SCRL fs |
|
|
# Copyright 2019 Coop IT Easy SCRL fs |
|
|
# Houssine BAKKALI <houssine@coopiteasy.be> |
|
|
# Houssine BAKKALI <houssine@coopiteasy.be> |
|
|
|
|
|
# Robin Keunen <robin@coopiteasy.be> |
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
|
|
|
from odoo import fields, models, api |
|
|
from odoo import fields, models, api |
|
@ -23,7 +24,8 @@ class ResPartner(models.Model): |
|
|
@api.depends("loan_line_ids", "loan_line_ids.state") |
|
|
@api.depends("loan_line_ids", "loan_line_ids.state") |
|
|
def _compute_is_loaner(self): |
|
|
def _compute_is_loaner(self): |
|
|
for partner in self: |
|
|
for partner in self: |
|
|
loans = partner.loan_line_ids.filtered( |
|
|
|
|
|
|
|
|
sudo_partner = partner.sudo() |
|
|
|
|
|
loans = sudo_partner.loan_line_ids.filtered( |
|
|
lambda l: l.state in ["subscribed", "waiting", "paid"] |
|
|
lambda l: l.state in ["subscribed", "waiting", "paid"] |
|
|
) |
|
|
) |
|
|
partner.is_loaner = bool(loans) |
|
|
|
|
|
|
|
|
sudo_partner.is_loaner = bool(loans) |