[FIX] HR sign in/sign out

bzr revid: fde@openerp.com-20101229123900-mxl4umxn1tqjjpar
This commit is contained in:
François Degrave 2010-12-29 13:39:00 +01:00
parent b2270b1a27
commit b05d9cfe25
3 changed files with 12 additions and 15 deletions

View File

@ -137,7 +137,7 @@ class hr_employee(osv.osv):
res = {'action': type, 'employee_id': emp['id']}
if dt:
res['name'] = dt
res['name'] = dt
id = obj_attendance.create(cr, uid, res, context=context)
if type != 'action':
@ -146,4 +146,4 @@ class hr_employee(osv.osv):
hr_employee()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -4,3 +4,4 @@
"access_hr_resource_manager","hr.employee.resource.manager","resource.model_resource_resource","base.group_hr_manager",1,1,1,1
"access_hr_resource_calendar_user","hr.employee.resource.calendar.user","resource.model_resource_calendar","base.group_hr_user",1,1,1,1
"access_hr_contract_type_manager","hr.contract.type.manager","model_hr_contract_type","base.group_hr_manager",1,1,1,1
"access_hr_contract_manager","hr.contract.manager","model_hr_contract","base.group_hr_manager",1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
4 access_hr_resource_manager hr.employee.resource.manager resource.model_resource_resource base.group_hr_manager 1 1 1 1
5 access_hr_resource_calendar_user hr.employee.resource.calendar.user resource.model_resource_calendar base.group_hr_user 1 1 1 1
6 access_hr_contract_type_manager hr.contract.type.manager model_hr_contract_type base.group_hr_manager 1 1 1 1
7 access_hr_contract_manager hr.contract.manager model_hr_contract base.group_hr_manager 1 1 1 1

View File

@ -237,27 +237,23 @@ class hr_timesheet_sheet(osv.osv):
self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context)
return True
def sign_in(self, cr, uid, ids, context=None):
def sign(self, cr, uid, ids, typ, context=None):
emp_obj = self.pool.get('hr.employee')
sheet = self.browse(cr, uid, ids, context=context)[0]
if context is None:
context = {}
if not self.browse(cr, uid, ids, context=context)[0].date_current == time.strftime('%Y-%m-%d'):
if not sheet.date_current == time.strftime('%Y-%m-%d'):
raise osv.except_osv(_('Error !'), _('You can not sign in from an other date than today'))
emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
emp_id = sheet.employee_id.id
context['sheet_id']=ids[0]
emp_obj.attendance_action_change(cr, uid, emp_ids, type='sign_in', context=context,)
emp_obj.attendance_action_change(cr, uid, [emp_id], type=typ, context=context,)
return True
def sign_in(self, cr, uid, ids, context=None):
return self.sign(cr,uid,ids,'sign_in',context=None)
def sign_out(self, cr, uid, ids, context=None):
emp_obj = self.pool.get('hr.employee')
if context is None:
context = {}
if not self.browse(cr, uid, ids, context=context)[0].date_current == time.strftime('%Y-%m-%d'):
raise osv.except_osv(_('Error !'), _('You can not sign out from an other date than today'))
emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)])
context['sheet_id']=ids[0]
emp_obj.attendance_action_change(cr, uid, emp_ids, type='sign_out', context=context,)
return True
return self.sign(cr,uid,ids,'sign_out',context=None)
_columns = {
'name': fields.char('Description', size=64, select=1,