[IMP] sale_timesheet: set default project in action

This commit add first project as default project of timesheet
in 'Hours Recorded' stat button's action.

task-2826265

Part-of: odoo/odoo#90744
This commit is contained in:
Kartik Chavda
2022-08-08 10:50:22 +02:00
parent a520745230
commit aef440b38e
@@ -98,6 +98,14 @@ class SaleOrder(models.Model):
action['context'] = {
'search_default_billable_timesheet': True
} # erase default filters
if self.order_line:
tasks = self.order_line.task_id._filter_access_rules_python('write')
if tasks:
action['context']['default_task_id'] = tasks[0].id
else:
projects = self.order_line.project_id._filter_access_rules_python('write')
if projects:
action['context']['default_project_id'] = projects[0].id
if self.timesheet_count > 0:
action['domain'] = [('so_line', 'in', self.order_line.ids)]
else: