From 2e124663e431326a75998bf4c5d37077efb3ec26 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Fri, 8 Apr 2022 10:22:12 +0000 Subject: [PATCH] [FIX] project_purchase: display the form if only one record to display Before this commit, when the user clicks on the Purchase Order row in costs of project profitability section displayed in right side panel, the action redirects the user to the list view of `Purchase Order Line` even if there is only one record. This commit fixes the issue to display the form view when there is only one record to display. task-2814466 closes odoo/odoo#88219 Related: odoo/enterprise#26004 Signed-off-by: Yannick Tivisse (yti) --- addons/project_purchase/models/project.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/project_purchase/models/project.py b/addons/project_purchase/models/project.py index 6861ea62ac9..9de301d16d2 100644 --- a/addons/project_purchase/models/project.py +++ b/addons/project_purchase/models/project.py @@ -58,10 +58,18 @@ class Project(models.Model): 'domain': domain, 'context': { 'create': False, + 'edit': False, }, } if res_id: action['res_id'] = res_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'] + action['view_mode'] = 'form' return action return super().action_profitability_items(section_name, domain, res_id)