From 9277ee37debbf75770793c6cf80a69a7366e24b4 Mon Sep 17 00:00:00 2001 From: "robin.keunen" Date: Wed, 4 Dec 2019 16:43:30 +0100 Subject: [PATCH] [REF] emc: reorder functions and use list comprehensions --- easy_my_coop/models/partner.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/easy_my_coop/models/partner.py b/easy_my_coop/models/partner.py index af0569b..414f608 100644 --- a/easy_my_coop/models/partner.py +++ b/easy_my_coop/models/partner.py @@ -53,14 +53,6 @@ class ResPartner(models.Model): for partner, child_ids in all_partners_and_children.items(): partner.total_invoiced = sum(price['total'] for price in price_totals if price['partner_id'] in child_ids) - @api.multi - def _get_share_type(self): - product_obj = self.env['product.product'] - share_type_list = [('', '')] - for share_type in product_obj.search([('is_share', '=', True)]): - share_type_list.append((str(share_type.id), share_type.short_name)) - return share_type_list - @api.multi @api.depends('share_ids') def _compute_effective_date(self): @@ -69,6 +61,15 @@ class ResPartner(models.Model): if partner.share_ids: partner.effective_date = partner.share_ids[0].effective_date + @api.multi + def _get_share_type(self): + shares = ( + self.env['product.product'] + .search([('is_share', '=', True)]) + ) + share_types = [(share.id, share.short_name) for share in shares] + return [('', '')] + share_types + @api.multi @api.depends('share_ids') def _compute_cooperator_type(self):