From 4e9138f8f9852d92d80c7fe4223fb6bfb516a737 Mon Sep 17 00:00:00 2001 From: Kishan Gajjar <kig@odoo.com> Date: Thu, 7 Dec 2017 11:55:39 +0530 Subject: [PATCH] [IMP]hr_timesheet: Only reset task_id if project_id is different thant task_id.project_id - set employee_id if there is default_employee_id in context --- addons/hr_timesheet/models/hr_timesheet.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index ee1d5833fb0f..ded21bd35b65 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -10,7 +10,7 @@ class AccountAnalyticLine(models.Model): @api.model def default_get(self, field_list): result = super(AccountAnalyticLine, self).default_get(field_list) - if 'employee_id' in field_list and result.get('user_id'): + if not self.env.context.get('default_employee_id') and 'employee_id' in field_list and result.get('user_id'): result['employee_id'] = self.env['hr.employee'].search([('user_id', '=', result['user_id'])], limit=1).id return result @@ -22,7 +22,8 @@ class AccountAnalyticLine(models.Model): @api.onchange('project_id') def onchange_project_id(self): - self.task_id = False + if self.project_id and self.project_id != self.task_id.project_id: + self.task_id = False @api.onchange('employee_id') def _onchange_employee_id(self): -- GitLab