Browse Source

[IMP] 008-z-C : enlever le type de coopérateur sur anciens coopérateurs: when share number is 0, you have no cooperator type anymore

pull/134/head
Thibault Francois 7 years ago
committed by Rémy Taymans
parent
commit
eaf19fc5c1
  1. 8
      beesdoo_easy_my_coop/models/res_partner.py

8
beesdoo_easy_my_coop/models/res_partner.py

@ -7,11 +7,13 @@ class Partner(models.Model):
cooperator_type = fields.Selection(selection='_get_share_type', compute='_compute_share_type', string='Cooperator Type', store=True) cooperator_type = fields.Selection(selection='_get_share_type', compute='_compute_share_type', string='Cooperator Type', store=True)
@api.multi @api.multi
@api.depends('share_ids', 'share_ids.share_product_id', 'share_ids.share_product_id.default_code')
@api.depends('share_ids', 'share_ids.share_product_id', 'share_ids.share_product_id.default_code', 'share_ids.share_number')
def _compute_share_type(self): def _compute_share_type(self):
for rec in self: for rec in self:
codes = rec.share_ids.mapped('share_product_id.default_code')
rec.cooperator_type = codes[0] if codes else ''
if rec.share_ids and rec.share_ids[0].share_number > 0:
rec.cooperator_type = rec.share_ids[0].share_product_id.default_code
else:
rec.cooperator_type = ''
@api.multi @api.multi
def _get_share_type(self): def _get_share_type(self):

Loading…
Cancel
Save