Add family members to membership invoice

This commit is contained in:
Youssef Elouahby 2018-10-29 22:53:09 +00:00
parent 95426c0e90
commit 7911a9c630

View File

@ -34,10 +34,14 @@ class GolemMembershipInvoice(models.TransientModel):
""" Set partner domain if src_member_id is filled """ """ Set partner domain if src_member_id is filled """
self.ensure_one() self.ensure_one()
record = self[0] record = self[0]
domain = ([('id', 'in', if record.src_member_id.is_minor:
record.src_member_id.mapped('legal_guardian_ids.legal_guardian_id').ids)] partner_ids = record.src_member_id.mapped('legal_guardian_ids.legal_guardian_id').ids
if record.src_member_id.is_minor else []) else:
return {'domain': {'partner_id': domain}} partner_ids = []
if hasattr(record.src_member_id, 'family_member_ids'):
partner_ids += record.src_member_id.family_member_ids.filtered(
lambda r: r.id != self.src_member_id.partner_id.id).ids
return {'domain': {'partner_id': [('id', 'in', partner_ids)]}}
@api.multi @api.multi
def membership_invoice(self): def membership_invoice(self):