You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.0 KiB

  1. from odoo import models, fields, api
  2. class Partner(models.Model):
  3. _inherit = 'res.partner'
  4. can_shop = fields.Boolean(compute='_can_shop', store=True)
  5. info_session_confirmed = fields.Boolean(
  6. string="Confirmed presence to info session",
  7. default=False,
  8. )
  9. @api.depends('cooperator_type',
  10. 'cooperative_status_ids',
  11. 'cooperative_status_ids.can_shop')
  12. def _can_shop(self):
  13. product_obj = self.env['product.template']
  14. can_shop_shares = product_obj.search([('is_share', '=', True),
  15. ('can_shop', '=', True)
  16. ]).mapped('default_code')
  17. for rec in self:
  18. if rec.cooperator_type in can_shop_shares:
  19. rec.can_shop = True
  20. elif (rec.cooperative_status_ids
  21. and rec.cooperative_status_ids[0].can_shop):
  22. rec.can_shop = True
  23. else:
  24. rec.can_shop = False