summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2017-07-05 09:58:34 +0200
committerGoffin Simon <sig@odoo.com>2017-07-05 13:43:23 +0200
commit0010be44bbf494b9b8f54eeef43ebfafa3d9694c (patch)
tree2158f7d8cdd19d7c48a542ddab5af30e21ed58f1 /addons
parent8810cee440e3fe4cbe03203a1daa6458ef70d985 (diff)
[FIX] hr_timesheet: create a sub task
When creating a sub task, the field default_parent_id is set in the context. When a sub task is created, a mail.compose.message was created with the same context. So the default parent_id set in the context (for a project.task record) was used to create the message and an error was raised in function get_record_data. opw:749435
Diffstat (limited to 'addons')
-rw-r--r--addons/hr_timesheet/project_timesheet.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/addons/hr_timesheet/project_timesheet.py b/addons/hr_timesheet/project_timesheet.py
index 400d5aedc6f..8a50f3c1ef4 100644
--- a/addons/hr_timesheet/project_timesheet.py
+++ b/addons/hr_timesheet/project_timesheet.py
@@ -67,3 +67,12 @@ class Task(models.Model):
for task in self:
if task.parent_id and task.parent_id.project_id and task.project_id and task.project_id != task.parent_id.project_id.subtask_project_id:
raise UserError(_("You can't define a parent task if its project is not correctly configured. The sub-task's project of the parent task's project should be this task's project"))
+
+ @api.model
+ def create(self, vals):
+ context = dict(self.env.context)
+ # Remove default_parent_id to avoid a confusion in get_record_data
+ if context.get('default_parent_id', False):
+ vals['parent_id'] = context.pop('default_parent_id', None)
+ task = super(Task, self.with_context(context)).create(vals)
+ return task