summaryrefslogtreecommitdiff
path: root/addons/project/models
diff options
context:
space:
mode:
authorfw-bot <otis@odoo.com>2020-01-13 16:04:06 +0000
committerjdoutreloux <jud@odoo.com>2020-01-15 15:11:50 +0100
commitfccaa703c4927ca906ccef329725ab00d3262051 (patch)
tree3e0d17cd8963601b553f1979ec58bb18eb7b39f9 /addons/project/models
parent1dc3301332f2b329c2aed0a7a3a4ae6c242e4655 (diff)
[MERGE] project, hr_expense: Fix several multi-company issues + tests
Purpose Fix multi-company access issues following the big changes that happened (the 13.0). Make the usability better in order to avoid potential multi-company issues for the user. Specification Check the related commits to see the different fixes that have been made. For more information about the technical/functional considerations, check the related task. Taskid: 2088891 X-original-commit: 5c8df3a5e5f7960e5eab6439e0a32a06224ba826
Diffstat (limited to 'addons/project/models')
-rw-r--r--addons/project/models/project.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py
index 1a981c5a759..2c5c6a5c8b2 100644
--- a/addons/project/models/project.py
+++ b/addons/project/models/project.py
@@ -665,6 +665,11 @@ class Task(models.Model):
self.company_id = self.project_id.company_id
else:
self.stage_id = False
+
+ @api.onchange('company_id')
+ def _onchange_task_company(self):
+ if self.project_id.company_id != self.company_id:
+ self.project_id = False
@api.constrains('parent_id', 'child_ids')
def _check_subtask_level(self):
@@ -943,8 +948,21 @@ class Task(models.Model):
if not children:
return self.env['project.task']
return children + children._get_all_subtasks()
+ def action_open_parent_task(self):
+ if self.sudo().parent_id and self.sudo().parent_id.company_id.id not in self.env.companies.ids:
+ raise UserError(_('The parent task belongs to a company you do not have access to.'))
+ return {
+ 'name': _('Parent Task'),
+ 'view_mode': 'form',
+ 'res_model': 'project.task',
+ 'res_id': self.parent_id.id,
+ 'type': 'ir.actions.act_window',
+ 'context': dict(self._context, create=False)
+ }
def action_subtask(self):
+ if self.sudo().subtask_project_id and self.sudo().subtask_project_id.company_id.id not in self.env.companies.ids:
+ raise UserError(_('The subtasks belong to a company you do not have access to.'))
action = self.env.ref('project.project_task_action_sub_task').read()[0]
# display all subtasks of current task