From 2562801d6339be2b8cd398627b6962f3d762fcd1 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Sat, 5 Mar 2022 12:45:40 +0100 Subject: [PATCH] [IMP] project_mrp: add action for MO in project profitability Before this commit, the Manufacturing orders are displayed in the costs but the user sees which MO impacts the costs of the project profitability. This commit adds an action to allow the users to see all the MO related to the project. However, the MO section will be clickable in the project profitability only if the user has access to the MO. task-2710808 --- addons/project_mrp/models/project.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/project_mrp/models/project.py b/addons/project_mrp/models/project.py index d223df8aa06..942ef0d9002 100644 --- a/addons/project_mrp/models/project.py +++ b/addons/project_mrp/models/project.py @@ -43,8 +43,8 @@ class Project(models.Model): [('category', '!=', 'manufacturing_order')], ]) - def _get_profitability_items(self): - profitability_items = super()._get_profitability_items() + def _get_profitability_items(self, with_action=True): + profitability_items = super()._get_profitability_items(with_action) mrp_category = 'manufacturing_order' mrp_aal_read_group = self.env['account.analytic.line'].sudo()._read_group( [('account_id', 'in', self.analytic_account_id.ids), ('category', '=', mrp_category)], @@ -52,12 +52,15 @@ class Project(models.Model): ['account_id'], ) if mrp_aal_read_group: + can_see_manufactoring_order = with_action and len(self) == 1 and self.user_has_groups('mrp.group_mrp_user') mrp_costs = { 'id': mrp_category, 'name': _lt('Manufacturing Orders'), 'billed': sum([res['amount'] for res in mrp_aal_read_group]), 'to_bill': 0.0, } + if can_see_manufactoring_order: + mrp_costs['action'] = {'name': 'action_view_mrp_production', 'type': 'object'} costs = profitability_items['costs'] costs['data'].append(mrp_costs) costs['total']['billed'] += mrp_costs['billed']