diff options
| author | Martin Trigaux <mat@odoo.com> | 2020-05-25 07:04:52 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2020-08-17 09:09:02 +0000 |
| commit | 6156f98288b16f6c84d36bacf16d5a66a661abb3 (patch) | |
| tree | 7a760d990d660640fed108a5d1fb5c8ce62a52e5 /addons/project | |
| parent | d5c16492397047ceb97a0879aa61f068a0eeeca8 (diff) | |
[FIX] *: adapt action content retrieval
Use _for_xml_id to replace all the self.env.ref().read()[0]
This has the advantage of having a single point of control and to add
the fields filtering and model verification.
Add sudo for other operations on ir.actions.*
Diffstat (limited to 'addons/project')
| -rw-r--r-- | addons/project/models/project.py | 8 | ||||
| -rw-r--r-- | addons/project/wizard/project_delete_wizard.py | 2 | ||||
| -rw-r--r-- | addons/project/wizard/project_task_type_delete.py | 6 |
3 files changed, 9 insertions, 7 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 374e5dcda48..d2b8e97d264 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -429,13 +429,15 @@ class Project(models.Model): favorite_projects.write({'favorite_user_ids': [(3, self.env.uid)]}) def action_view_tasks(self): - action = self.with_context(active_id=self.id, active_ids=self.ids).env.ref('project.act_project_project_2_project_task_all').read()[0] + action = self.with_context(active_id=self.id, active_ids=self.ids) \ + .env.ref('project.act_project_project_2_project_task_all') \ + .sudo().read()[0] action['display_name'] = self.name return action def action_view_account_analytic_line(self): """ return the action to see all the analytic lines of the project's analytic account """ - action = self.env.ref('analytic.account_analytic_line_action').read()[0] + action = self.env["ir.actions.actions"]._for_xml_id("analytic.account_analytic_line_action") action['context'] = {'default_account_id': self.analytic_account_id.id} action['domain'] = [('account_id', '=', self.analytic_account_id.id)] return action @@ -1320,7 +1322,7 @@ class Task(models.Model): } def action_subtask(self): - action = self.env.ref('project.project_task_action_sub_task').read()[0] + action = self.env["ir.actions.actions"]._for_xml_id("project.project_task_action_sub_task") # display all subtasks of current task action['domain'] = [('id', 'child_of', self.id), ('id', '!=', self.id)] diff --git a/addons/project/wizard/project_delete_wizard.py b/addons/project/wizard/project_delete_wizard.py index 7289de88687..9dff0454549 100644 --- a/addons/project/wizard/project_delete_wizard.py +++ b/addons/project/wizard/project_delete_wizard.py @@ -25,4 +25,4 @@ class ProjectDelete(models.TransientModel): def confirm_delete(self): self.with_context(active_test=False).project_ids.unlink() - return self.env.ref('project.open_view_project_all_config').read()[0] + return self.env["ir.actions.actions"]._for_xml_id("project.open_view_project_all_config") diff --git a/addons/project/wizard/project_task_type_delete.py b/addons/project/wizard/project_task_type_delete.py index 4e8f8f4e20e..7efbd55df57 100644 --- a/addons/project/wizard/project_task_type_delete.py +++ b/addons/project/wizard/project_task_type_delete.py @@ -55,16 +55,16 @@ class ProjectTaskTypeDelete(models.TransientModel): project_id = self.env.context.get('default_project_id') if project_id: - action = self.env.ref('project.action_view_task').read()[0] + action = self.env["ir.actions.actions"]._for_xml_id("project.action_view_task") action['domain'] = [('project_id', '=', project_id)] action['context'] = str({ 'pivot_row_groupby': ['user_id'], 'default_project_id': project_id, }) elif self.env.context.get('stage_view'): - action = self.env.ref('project.open_task_type_form').read()[0] + action = self.env["ir.actions.actions"]._for_xml_id("project.open_task_type_form") else: - action = self.env.ref('project.action_view_all_task').read()[0] + action = self.env["ir.actions.actions"]._for_xml_id("project.action_view_all_task") context = dict(ast.literal_eval(action.get('context')), active_test=True) action['context'] = context |
