From dd2354a1abc4365af8bda7f34a303b9bacc4e644 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 20 Jun 2018 15:30:30 +0200 Subject: [PATCH] [FIX] sale_timesheet: SO line on subtask - Activate sub-stasks on projects - Create a product A: Product Type: Service Invoice based on: Timesheets on tasks Service Tracking: Create a task in an existing project - Create a SO with A, validate - In the project view, open the created task - Click on the stat button 'Sub-tasks' - Create a task from the kanban view The SO line is not copied on the sub-task. The `name_create` method doesn't send the `parent_id` key in the values. Therefore, the SO line is not retrieved. We fallback on the context key `default_parent_id`. opw-1857560 --- addons/sale_timesheet/models/project.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index 1ba9e3cd53e..385525cbada 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -70,8 +70,9 @@ class ProjectTask(models.Model): @api.model def create(self, values): # sub task has the same so line than their parent - if 'parent_id' in values and values['parent_id']: - values['sale_line_id'] = self.env['project.task'].browse(values['parent_id']).sudo().sale_line_id.id + parent_id = values['parent_id'] if 'parent_id' in values else self.env.context.get('default_parent_id') + if parent_id: + values['sale_line_id'] = self.env['project.task'].browse(parent_id).sudo().sale_line_id.id return super(ProjectTask, self).create(values) @api.multi