[FIX] hr_timesheet: handle case when has never signed in

The search may return zero results if an employee has never signed in. In this case the browse would have failed.
This commit is contained in:
Oliver Laurent 2014-07-18 11:53:19 +02:00 committed by Martin Trigaux
parent a5efa93b93
commit 1c9e8ba077
1 changed files with 9 additions and 6 deletions

View File

@ -61,6 +61,7 @@ class hr_attendance(osv.osv):
('employee_id', '=', obj.employee_id.id),
('name', '<', obj.name), ('action', '=', 'sign_in')
], limit=1, order='name DESC')
if last_signin:
last_signin = self.browse(cr, uid, last_signin_id, context=context)[0]
# Compute time elapsed between sign-in and sign-out
@ -68,6 +69,8 @@ class hr_attendance(osv.osv):
signout_datetime = datetime.strptime(obj.name, '%Y-%m-%d %H:%M:%S')
workedhours_datetime = (signout_datetime - last_signin_datetime)
res[obj.id] = ((workedhours_datetime.seconds) / 60) / 60
else:
res[obj.id] = False
return res
_columns = {