[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
This commit is contained in:
jem-odoo
2018-07-05 10:16:42 +02:00
parent 4edcc1f322
commit ceaa6562a5
2 changed files with 7 additions and 2 deletions
@@ -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
@@ -43,7 +43,7 @@
<field name="date"/>
<field name="name"/>
<field name="project_id" required="1"/>
<field name="task_id" context="{'default_project_id': project_id}" domain="[('project_id', '=', project_id)]"/>
<field name="task_id" context="{'default_project_id': project_id}"/>
<field name="unit_amount" string="Time (Hours)" sum="Total time" widget="float_time"/>
</tree>
</field>
@@ -88,7 +88,7 @@
<field name="date"/>
<field name="name"/>
<field name="project_id" required="1"/>
<field name="task_id" domain="[('project_id', '=', project_id)]"/>
<field name="task_id"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<group>