Created
June 4, 2016 02:30
-
-
Save holdenrehg/571ceb59d963f2cf7ec4de309d6005c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import logging | |
from openerp import api, models, fields | |
_logger = logging.getLogger(__name__) | |
class PartnerGroup(models.Model): | |
_name = 'res.partner.group' | |
name = fields.Char('Group Name') | |
partner_ids = fields.One2many('res.partner', 'partner_group_id', 'Partners') | |
has_late_bills = fields.Boolean('Has Late Bills', compute='compute_has_late_bills') | |
@api.multi | |
@api.depends('partner_ids.has_late_bills', 'partner_ids.invoice_ids') | |
def compute_has_late_bills(self): | |
""" | |
Computes if this partner group has late bills based on | |
if any of the partners in the group have late bills. | |
""" | |
for group in self: | |
_logger.info('DEPENDS_TEST: computing late bills for partner group ' + str(group.id)) | |
for partner in group.partner_ids: | |
if partner.has_late_bills: | |
group.has_late_bills = True | |
return | |
group.has_late_bills = False | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment