diff --git a/addons/hr_attendance/wizard/sign_in_out.py b/addons/hr_attendance/wizard/sign_in_out.py index b3c253219bf..fcaa456cd3c 100644 --- a/addons/hr_attendance/wizard/sign_in_out.py +++ b/addons/hr_attendance/wizard/sign_in_out.py @@ -87,7 +87,7 @@ def _sign_out(self, cr, uid, data, context): service = netsvc.LocalService('object_proxy') emp_id = data['form']['emp_id'] if 'last_time' in data['form'] : - if data['form']['last_time'] > time.strftime('%Y-%m-%d'): + if data['form']['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'): raise wizard.except_wizard(_('UserError'), _('The Sign-in date must be in the past')) return {'success': False} service.execute(cr.dbname, uid, 'hr.attendance', 'create', {'name':data['form']['last_time'], 'action':'sign_in', 'employee_id':emp_id}) @@ -100,7 +100,7 @@ def _sign_out(self, cr, uid, data, context): so_ask_form ='''
''' @@ -123,7 +123,7 @@ def _si_check(self, cr, uid, data, context): si_ask_form =''' ''' @@ -133,14 +133,23 @@ si_ask_fields = { 'last_time' : {'string' : "Your last sign in", 'type' : 'datetime', 'required' : True}, } +so_wo_si_form = ''' +''' + def _so_check(self, cr, uid, data, context): states = {True : 'so', False: 'so_ask_si'} service = netsvc.LocalService('object_proxy') emp_id = data['form']['emp_id'] - att_id = service.execute(cr.dbname, uid, 'hr.attendance', 'search', [('employee_id', '=', emp_id)], limit=1, order='name desc') + att_id = service.execute(cr.dbname, uid, 'hr.attendance', 'search', [('employee_id', '=', emp_id),('action','!=','action')], limit=1, order='name desc') last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id) if last_att: last_att = last_att[0] + + if not att_id and not last_att: + return 'so_wo_si' + cond = last_att and last_att['action'] == 'sign_in' return states[cond] @@ -174,6 +183,10 @@ class wiz_si_so(wizard.interface): 'actions' : [_sign_out], 'result' : {'type' : 'state', 'state':'end'} }, + 'so_wo_si' : { + 'actions' : [], + 'result' : {'type' : 'form', 'arch' : so_wo_si_form, 'fields' : {}, 'state' : [('end', 'Ok')] } + }, } wiz_si_so('hr.si_so')