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/models/project.py | |
| 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/models/project.py')
| -rw-r--r-- | addons/project/models/project.py | 8 |
1 files changed, 5 insertions, 3 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)] |
