From 3c5de9490acedbadcd1ba45bbf5dc214d60ca9d2 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 7 Apr 2022 09:05:19 +0000 Subject: [PATCH] [IMP] project_mrp: add help message when no record in MRP action Before this commit, when the user clicks on "Manufactoring" row in Project Profitability section displayed in right side panel the user arrives in the tree view if there are more than one record. If he filters the records and found no record then no help message is shown, he has just an empty list view. This commit adds a help message for that action to dislplay it when no record is shown in the list view (or another view) for this action. task-2814466 Part-of: odoo/odoo#88219 --- addons/project_mrp/models/project.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/project_mrp/models/project.py b/addons/project_mrp/models/project.py index 9367841e636..62827c7b9cc 100644 --- a/addons/project_mrp/models/project.py +++ b/addons/project_mrp/models/project.py @@ -14,9 +14,18 @@ class Project(models.Model): def action_view_mrp_production(self): self.ensure_one() - action = self.analytic_account_id.action_view_mrp_production() - if self.production_count > 1: - action["view_mode"] = 'tree,form,kanban,calendar,pivot,graph' + action = self.env['ir.actions.actions']._for_xml_id('mrp.mrp_production_action') + action['domain'] = [('analytic_account_id', '=', self.analytic_account_id.id)] + action['context'] = {'default_analytic_account_id': self.analytic_account_id.id} + if self.production_count == 1: + action['view_mode'] = 'form' + action['res_id'] = self.analytic_account_id.production_ids.id + if 'views' in action: + action['views'] = [ + (view_id, view_type) + for view_id, view_type in action['views'] + if view_type == 'form' + ] or [False, 'form'] return action def action_view_mrp_bom(self):