summaryrefslogtreecommitdiff
path: root/addons/hr_timesheet
diff options
context:
space:
mode:
authorVictor Feyens <vfe@odoo.com>2020-07-14 14:32:37 +0000
committerVictor Feyens <vfe@odoo.com>2020-07-23 16:38:17 +0000
commit5dc8b7bdd8ea8a760d1929333cd8461047e5b4e6 (patch)
treea726b57bea6d1f801f802767396e2f7f736725c4 /addons/hr_timesheet
parent71ab12840bc787ca486202255cd6faa21281b9e1 (diff)
[IMP] *: replace default_get overrides by default attribute on fields.
Leave the generic management of fields default to the orm as much as possible. * Default method is not called unless necessary. * Default values are correctly post-processed by the orm when necessary.
Diffstat (limited to 'addons/hr_timesheet')
-rw-r--r--addons/hr_timesheet/wizard/project_task_create_timesheet.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/addons/hr_timesheet/wizard/project_task_create_timesheet.py b/addons/hr_timesheet/wizard/project_task_create_timesheet.py
index e55043e982d..b919361822b 100644
--- a/addons/hr_timesheet/wizard/project_task_create_timesheet.py
+++ b/addons/hr_timesheet/wizard/project_task_create_timesheet.py
@@ -11,18 +11,13 @@ class ProjectTaskCreateTimesheet(models.TransientModel):
_sql_constraints = [('time_positive', 'CHECK(time_spent > 0)', 'The timesheet\'s time must be positive' )]
- @api.model
- def default_get(self, fields):
- result = super(ProjectTaskCreateTimesheet, self).default_get(fields)
-
- active_id = self._context.get('active_id')
- if 'task_id' in fields and active_id:
- result['task_id'] = active_id
- return result
-
time_spent = fields.Float('Time', digits=(16, 2))
description = fields.Char('Description')
- task_id = fields.Many2one('project.task', "Task", help="Task for which we are creating a sales order", required=True)
+ task_id = fields.Many2one(
+ 'project.task', "Task", required=True,
+ default=lambda self: self.env.context.get('active_id', None),
+ help="Task for which we are creating a sales order",
+ )
def save_timesheet(self):
values = {