Skip to content

Instantly share code, notes, and snippets.

@holdenrehg
Last active June 4, 2016 02:15
Show Gist options
  • Save holdenrehg/ad0ee0253e74bd5d76f35c86e83eba52 to your computer and use it in GitHub Desktop.
Save holdenrehg/ad0ee0253e74bd5d76f35c86e83eba52 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import logging
from openerp import api, fields, models
_logger = logging.getLogger(__name__)
class Partner(models.Model):
_inherit = 'res.partner'
partner_group_id = fields.Many2one('res.partner.group')
has_late_bills = fields.Boolean('Has Late Bills', compute='compute_has_late_bills')
@api.multi
@api.depends('invoice_ids')
def compute_has_late_bills(self):
"""
Computes if this partner has late bills based on
if any of the invoices attached to this group are late.
"""
for partner in self:
_logger.info('DEPENDS_TEST: computing late bills for partner ' + str(partner.id))
for invoice in partner.invoice_ids:
if invoice.is_late:
partner.has_late_bills = True
return
partner.has_late_bills = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment