[FIX] sale_project: editable views for action_view_task
Steps to reproduce ================== - Install sale_project,industry_fsm,web_studio - Open quotation S00023 - Click on the Tasks stat button - Open studio - Go to views - Enable the gantt view => Unable to complete the operation: duplicate key value violates unique constraint "act_window_view_unique_mode_per_action" Cause of the issue ================== The [action record] already contains the gantt view, but it is replaced inside the python [action]. In [previous] version, the user was entering this condition and thus had no problem editing the views Solution ======== Instead of replacing the entire action['views'], we can remap the view ids to the ones we want. One side effect of this though is that the `gantt,activity,map` views will be available by default. --- [action record]: https://github.com/odoo/enterprise/blob/1df090289f3c45c200d133734989a6d9a8073145/project_enterprise/views/project_task_views.xml#L227 [action]: https://github.com/odoo/odoo/blob/1a9302dc3a9b0d9323612c10e0f3a91300bb89fd/addons/sale_project/models/sale_order.py#L154 [previous]: https://github.com/odoo/odoo/blob/8dbcd3d955e7270fc26a6141e8fce751029e5a4b/addons/sale_project/models/sale_order.py#L133-L141 opw-3800071 closes odoo/odoo#163594 X-original-commit: e331798655f821b89c50a0f578dabeb6e03ecc78 Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com> Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
This commit is contained in:
@@ -150,7 +150,13 @@ class SaleOrder(models.Model):
|
||||
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("project.action_view_task")
|
||||
if self.tasks_count > 1: # cross project kanban task
|
||||
action['views'] = [[kanban_view_id, 'kanban'], [list_view_id, 'tree'], [form_view_id, 'form'], [False, 'graph'], [False, 'calendar'], [False, 'pivot']]
|
||||
for idx, (view_id, view_type) in enumerate(action['views']):
|
||||
if view_type == 'kanban':
|
||||
action['views'][idx] = (kanban_view_id, 'kanban')
|
||||
elif view_type == 'tree':
|
||||
action['views'][idx] = (list_view_id, 'tree')
|
||||
elif view_type == 'form':
|
||||
action['views'][idx] = (form_view_id, 'form')
|
||||
else: # 1 or 0 tasks -> form view
|
||||
action['views'] = [(form_view_id, 'form')]
|
||||
action['res_id'] = self.tasks_ids.id
|
||||
|
||||
Reference in New Issue
Block a user