From ceaa6562a585e4098c0981812e47d120d7c9f96e Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Thu, 5 Jul 2018 09:33:22 +0200 Subject: [PATCH] [FIX] hr_timesheet: dynamic domain when encoding timesheet To have a better encoding timesheet, we want for the user: 1/ when selecting project first, the task proposed will be the ones in the project. When changing project, it reset the task to empty. 2/ when selecting the task first, the project will be the one from the task --- addons/hr_timesheet/models/hr_timesheet.py | 5 +++++ addons/hr_timesheet/views/hr_timesheet_views.xml | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index 5ec54373833..9aca9f0f0f5 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -32,6 +32,11 @@ class AccountAnalyticLine(models.Model): 'task_id': [('project_id', '=', self.project_id.id)] }} + @api.onchange('task_id') + def _onchange_task_id(self): + if not self.project_id: + self.project_id = self.task_id.project_id + @api.onchange('employee_id') def _onchange_employee_id(self): self.user_id = self.employee_id.user_id diff --git a/addons/hr_timesheet/views/hr_timesheet_views.xml b/addons/hr_timesheet/views/hr_timesheet_views.xml index caefdad4c90..ebdc5dd321a 100644 --- a/addons/hr_timesheet/views/hr_timesheet_views.xml +++ b/addons/hr_timesheet/views/hr_timesheet_views.xml @@ -43,7 +43,7 @@ - + @@ -88,7 +88,7 @@ - +