HR modif
bzr revid: pinky-0275d92f96daab9db9f1fd3835f27a70b7a266d7
This commit is contained in:
parent
6a99028203
commit
79f35ed912
|
@ -128,6 +128,7 @@ class hr_employee(osv.osv):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def sign_out(self, cr, uid, ids, context={}, dt=False, *args):
|
def sign_out(self, cr, uid, ids, context={}, dt=False, *args):
|
||||||
|
id = False
|
||||||
for emp in self.browse(cr, uid, ids):
|
for emp in self.browse(cr, uid, ids):
|
||||||
if not self._action_check(cr, uid, emp.id, dt, context):
|
if not self._action_check(cr, uid, emp.id, dt, context):
|
||||||
raise osv.except_osv('Warning', 'You tried to sign out with a date anterior to another event !\nTry to contact the administrator to correct attendances.')
|
raise osv.except_osv('Warning', 'You tried to sign out with a date anterior to another event !\nTry to contact the administrator to correct attendances.')
|
||||||
|
@ -136,7 +137,8 @@ class hr_employee(osv.osv):
|
||||||
res['name'] = dt
|
res['name'] = dt
|
||||||
att_id = self.pool.get('hr.attendance').create(cr, uid, res)
|
att_id = self.pool.get('hr.attendance').create(cr, uid, res)
|
||||||
self.write(cr, uid, [emp.id], {'state':'absent'})
|
self.write(cr, uid, [emp.id], {'state':'absent'})
|
||||||
return True
|
id = att_id
|
||||||
|
return id
|
||||||
|
|
||||||
def _action_check(self, cr, uid, emp_id, dt=False,context={}):
|
def _action_check(self, cr, uid, emp_id, dt=False,context={}):
|
||||||
cr.execute('select max(name) from hr_attendance where employee_id=%d', (emp_id,))
|
cr.execute('select max(name) from hr_attendance where employee_id=%d', (emp_id,))
|
||||||
|
@ -144,15 +146,16 @@ class hr_employee(osv.osv):
|
||||||
return not (res and (res[0]>=(dt or time.strftime('%Y-%m-%d %H:%M:%S'))))
|
return not (res and (res[0]>=(dt or time.strftime('%Y-%m-%d %H:%M:%S'))))
|
||||||
|
|
||||||
def sign_in(self, cr, uid, ids, context={}, dt=False, *args):
|
def sign_in(self, cr, uid, ids, context={}, dt=False, *args):
|
||||||
|
id = False
|
||||||
for emp in self.browse(cr, uid, ids):
|
for emp in self.browse(cr, uid, ids):
|
||||||
if not self._action_check(cr, uid, emp.id, dt, context):
|
if not self._action_check(cr, uid, emp.id, dt, context):
|
||||||
raise osv.except_osv('Warning', 'You tried to sign in with a date anterior to another event !\nTry to contact the administrator to correct attendances.')
|
raise osv.except_osv('Warning', 'You tried to sign in with a date anterior to another event !\nTry to contact the administrator to correct attendances.')
|
||||||
res = {'action':'sign_in', 'employee_id':emp.id}
|
res = {'action':'sign_in', 'employee_id':emp.id}
|
||||||
if dt:
|
if dt:
|
||||||
res['name'] = dt
|
res['name'] = dt
|
||||||
self.pool.get('hr.attendance').create(cr, uid, res)
|
id = self.pool.get('hr.attendance').create(cr, uid, res)
|
||||||
self.write(cr, uid, [emp.id], {'state':'present'})
|
self.write(cr, uid, [emp.id], {'state':'present'})
|
||||||
return True
|
return id
|
||||||
|
|
||||||
hr_employee()
|
hr_employee()
|
||||||
|
|
||||||
|
@ -192,10 +195,10 @@ class hr_attendance(osv.osv):
|
||||||
_name = "hr.attendance"
|
_name = "hr.attendance"
|
||||||
_description = "Attendance"
|
_description = "Attendance"
|
||||||
_columns = {
|
_columns = {
|
||||||
'name' : fields.datetime('Date'),
|
'name' : fields.datetime('Date', required=True),
|
||||||
'action' : fields.selection([('sign_in', 'Sign In'), ('sign_out', 'Sign Out'),('action','Action')], 'Action'),
|
'action' : fields.selection([('sign_in', 'Sign In'), ('sign_out', 'Sign Out'),('action','Action')], 'Action', required=True),
|
||||||
'action_desc' : fields.many2one("hr.action.reason", "Action reason", domain="[('action_type', '=', action)]"),
|
'action_desc' : fields.many2one("hr.action.reason", "Action reason", domain="[('action_type', '=', action)]"),
|
||||||
'employee_id' : fields.many2one('hr.employee', 'Employee',required=True, select=True),
|
'employee_id' : fields.many2one('hr.employee', 'Employee', required=True, select=True),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'name' : lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
'name' : lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
|
|
Loading…
Reference in New Issue