From 95a2d179308a2c9b5c86ec4bc8601434a880890e Mon Sep 17 00:00:00 2001 From: Date: Thu, 7 Jul 2011 14:27:59 +0200 Subject: [PATCH] [FIX] of last commit: allow to sign in / sign out on the sheet of an other employee bzr revid: guewen.baconnier@camptocamp.com-20110707122759-3919twq9v9sznuo4 --- .../wizard/hr_attendance_sign_in_out.py | 17 ++++++++++++++--- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py index 7a51c2b9e1e..89ca5148bbb 100644 --- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py +++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py @@ -33,14 +33,20 @@ class hr_si_so_ask(osv.osv_memory): } def _get_empname(self, cr, uid, context=None): - emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) + if context.get('emp_id', False): + emp_id = context['emp_id'] + else: + emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if emp_id: employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0].name return employee return '' def _get_empid(self, cr, uid, context=None): - emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) + if context.get('emp_id', False): + emp_id = context['emp_id'] + else: + emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if emp_id: return emp_id[0] return False @@ -72,7 +78,10 @@ class hr_sign_in_out(osv.osv_memory): } def _get_empid(self, cr, uid, context=None): - emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) + if context.get('emp_id', False): + emp_id = context['emp_id'] + else: + emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if emp_id: employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0] return {'name': employee.name, 'state': employee.state, 'emp_id': emp_id[0]} @@ -106,6 +115,7 @@ class hr_sign_in_out(osv.osv_memory): 'res_model': 'hr.sign.in.out.ask', 'views': [(resource_id,'form')], 'type': 'ir.actions.act_window', + 'context': context, 'target': 'new', } @@ -128,6 +138,7 @@ class hr_sign_in_out(osv.osv_memory): 'res_model': 'hr.sign.in.out', 'views': [(resource_id,'form')], 'type': 'ir.actions.act_window', + 'context': context, 'target': 'new', } diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 0cc0fbc11f7..7ba824814cf 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -254,6 +254,8 @@ class hr_timesheet_sheet(osv.osv): def sign(self, cr, uid, ids, typ, context=None): self.check_sign(cr, uid, ids, typ, context=context) sign_obj = self.pool.get('hr.sign.in.out') + sheet = self.browse(cr, uid, ids, context=context)[0] + context['emp_id'] = [sheet.employee_id.id] sign_id = sign_obj.create(cr, uid, {}, context=context) methods = {'sign_in': sign_obj.si_check, 'sign_out': sign_obj.so_check}