diff options
| author | Jérome Maes <jem@openerp.com> | 2017-06-07 13:00:58 +0200 |
|---|---|---|
| committer | Jérome Maes <jem@openerp.com> | 2017-06-09 13:12:07 +0200 |
| commit | 56948bb245b89fb6d4b6e6800a75f92c129aa1bc (patch) | |
| tree | dbeaba6539a83ef540057faea981d5741ed2deab /addons | |
| parent | 78fee1c6342ec137521cebedc7309dff432ff512 (diff) | |
[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.
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/hr_timesheet/hr_timesheet.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index 74704a459f2..d8d07c42fd8 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -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)]) |
