From 74faef8ba75a0e5a0c43a626b09548fa7e7e5dac Mon Sep 17 00:00:00 2001 From: bch <> Date: Fri, 9 Feb 2007 10:11:21 +0000 Subject: [PATCH] HR: Sign-in Sign-out : bugfix , the user is now not allowed to provide a date in the future bzr revid: bch-74e27a5bdf39ba56eb5c96aa5deed7b267df59ac --- addons/hr/wizard/sign_in_out.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/hr/wizard/sign_in_out.py b/addons/hr/wizard/sign_in_out.py index 6d5ffddcee7..ecfc4266f6f 100644 --- a/addons/hr/wizard/sign_in_out.py +++ b/addons/hr/wizard/sign_in_out.py @@ -29,6 +29,7 @@ import wizard import netsvc +import time si_so_form ='''
@@ -56,7 +57,7 @@ so_form = ''' -''' +''' so_fields = { 'success' : {'string' : "Sign out's status", 'type' : 'char', 'required' : True, 'readonly' : True}, @@ -73,7 +74,10 @@ def _get_empid(self, cr, uid, data, context): def _sign_in(self, cr, uid, data, context): service = netsvc.LocalService('object_proxy') emp_id = data['form']['emp_id'] - if 'last_time' in data['form']: + if 'last_time' in data['form'] : + if data['form']['last_time'] > time.strftime('%Y-%m-%d'): + raise wizard.except_wizard('UserError', 'The sign-out date must be in the past') + return {'success': False} service.execute(cr.dbname, uid, 'hr.attendance', 'create', { 'name': data['form']['last_time'], 'action': 'sign_out', @@ -81,6 +85,7 @@ def _sign_in(self, cr, uid, data, context): }) try: success = service.execute(cr.dbname, uid, 'hr.employee', 'sign_in', [emp_id]) + print success except: raise wizard.except_wizard('UserError', 'A sign-in must be right after a sign-out !') return {'success': success} @@ -88,7 +93,10 @@ def _sign_in(self, cr, uid, data, context): 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 'last_time' in data['form'] : + if data['form']['last_time'] > time.strftime('%Y-%m-%d'): + 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}) try: success = service.execute(cr.dbname, uid, 'hr.employee', 'sign_out', [emp_id])