[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) <yti@odoo.com>
This commit is contained in:
Xavier BOL (xbo)
2022-04-08 17:13:31 +02:00
parent e0824571f0
commit 2e124663e4
@@ -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)