[FIX] hr_timesheet: set correct default value for timesheet

When logging timesheet, no employee is set by
default on the UI. The employee is deduced
from the user_id in the create, but we want to
see it on the list view even if it is not saved
yet.
This commit is contained in:
Jérome Maes
2017-06-09 13:12:07 +02:00
parent 78fee1c634
commit 56948bb245
+7
View File
@@ -7,6 +7,13 @@ from odoo import api, fields, models
class AccountAnalyticLine(models.Model):
_inherit = 'account.analytic.line'
@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') and result.get('project_id'):
result['employee_id'] = self.env['hr.employee'].search([('user_id', '=', result['user_id'])], limit=1).id
return result
task_id = fields.Many2one('project.task', 'Task')
project_id = fields.Many2one('project.project', 'Project', domain=[('allow_timesheets', '=', True)])