From 1fd2a6a439b5b711408568b6a214109099cedcb8 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Sun, 24 Jun 2018 23:45:04 +0200 Subject: [PATCH] [ADD] Can shop field on res.partner that take into account the cooperator type and the cooperator status --- beesdoo_easy_my_coop/models/res_partner.py | 12 ++++++++++++ beesdoo_easy_my_coop/views/partner.xml | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/beesdoo_easy_my_coop/models/res_partner.py b/beesdoo_easy_my_coop/models/res_partner.py index 8507332..1bde775 100644 --- a/beesdoo_easy_my_coop/models/res_partner.py +++ b/beesdoo_easy_my_coop/models/res_partner.py @@ -5,6 +5,18 @@ class Partner(models.Model): _inherit = 'res.partner' cooperator_type = fields.Selection(selection='_get_share_type', compute='_compute_share_type', string='Cooperator Type', store=True) + can_shop = fields.Boolean(compute='_can_shop', store=True) + + @api.depends('cooperator_type', 'cooperative_status_ids', 'cooperative_status_ids.can_shop') + def _can_shop(self): + for rec in self: + if rec.cooperator_type == 'share_b': + rec.can_shop = True + elif rec.cooperative_status_ids and rec.cooperative_status_ids[0].can_shop: + rec.can_shop = True + else: + rec.can_shop = False + @api.multi @api.depends('share_ids', 'share_ids.share_product_id', 'share_ids.share_product_id.default_code', 'share_ids.share_number') diff --git a/beesdoo_easy_my_coop/views/partner.xml b/beesdoo_easy_my_coop/views/partner.xml index e479c63..ad869bf 100644 --- a/beesdoo_easy_my_coop/views/partner.xml +++ b/beesdoo_easy_my_coop/views/partner.xml @@ -27,9 +27,9 @@ - beesdoo.partner.form.view.remove_duplicate_cooperator_type + beesdoo.partner.form.view.remove_duplicate_header res.partner - + @@ -38,6 +38,9 @@