diff options
| author | Christophe Simonis <christophe@tinyerp.com> | 2008-07-22 17:11:28 +0200 |
|---|---|---|
| committer | Christophe Simonis <christophe@tinyerp.com> | 2008-07-22 17:11:28 +0200 |
| commit | d2ff95f66505842995786872924507f077c714dd (patch) | |
| tree | d4b4c59ee9ba927a2869522cad75e1f8cd5d2df2 /addons/hr/wizard | |
| parent | 2dd9723b8b3d38df8c8962300ab67afffa5cdaaa (diff) | |
replace tabs with 4 spaces
bzr revid: christophe@tinyerp.com-20080722151128-f5zy75tsn8pgtndd
Diffstat (limited to 'addons/hr/wizard')
| -rw-r--r-- | addons/hr/wizard/print_attendance_error.py | 36 | ||||
| -rw-r--r-- | addons/hr/wizard/print_bymonth.py | 30 | ||||
| -rw-r--r-- | addons/hr/wizard/print_byweek.py | 32 | ||||
| -rw-r--r-- | addons/hr/wizard/sign_in_out.py | 210 |
4 files changed, 154 insertions, 154 deletions
diff --git a/addons/hr/wizard/print_attendance_error.py b/addons/hr/wizard/print_attendance_error.py index 9939ae1e136..3d74bd936b4 100644 --- a/addons/hr/wizard/print_attendance_error.py +++ b/addons/hr/wizard/print_attendance_error.py @@ -32,29 +32,29 @@ import time _date_form = '''<?xml version="1.0"?> <form string="Select a time span"> - <separator string="Analysis Information" colspan="4"/> - <field name="init_date"/> - <field name="end_date"/> - <field name="max_delay"/> - <label string="Bellow this delay, the error is considered as volunteer" colspan="2"/> + <separator string="Analysis Information" colspan="4"/> + <field name="init_date"/> + <field name="end_date"/> + <field name="max_delay"/> + <label string="Bellow this delay, the error is considered as volunteer" colspan="2"/> </form>''' _date_fields = { - 'init_date': {'string':'Starting Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True}, - 'end_date': {'string':'Ending Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True}, - 'max_delay': {'string':'Max. Delay (Min)', 'type':'integer', 'default':lambda *a: 120, 'required':True}, + 'init_date': {'string':'Starting Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True}, + 'end_date': {'string':'Ending Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True}, + 'max_delay': {'string':'Max. Delay (Min)', 'type':'integer', 'default':lambda *a: 120, 'required':True}, } class wiz_attendance(wizard.interface): - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('print','Print Attendance Report'),('end','Cancel') ]} - }, - 'print': { - 'actions': [], - 'result': {'type': 'print', 'report': 'hr.timesheet.attendance.error', 'state':'end'} - } - } + states = { + 'init': { + 'actions': [], + 'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('print','Print Attendance Report'),('end','Cancel') ]} + }, + 'print': { + 'actions': [], + 'result': {'type': 'print', 'report': 'hr.timesheet.attendance.error', 'state':'end'} + } + } wiz_attendance('hr.timesheet.attendance.report') diff --git a/addons/hr/wizard/print_bymonth.py b/addons/hr/wizard/print_bymonth.py index 454fe58e7cd..3b0df25e9ba 100644 --- a/addons/hr/wizard/print_bymonth.py +++ b/addons/hr/wizard/print_bymonth.py @@ -32,26 +32,26 @@ import time _date_form = '''<?xml version="1.0"?> <form string="Select a month"> - <separator string="Select a month" colspan="4"/> - <field name="month"/> - <field name="year"/> + <separator string="Select a month" colspan="4"/> + <field name="month"/> + <field name="year"/> </form>''' _date_fields = { - 'month' : {'string' : 'Month', 'type' : 'selection', 'selection' : [(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')], 'required':True }, - 'year' : {'string' : 'Year', 'type' : 'integer', 'required':True, 'default' : lambda *a: time.gmtime()[0]}, + 'month' : {'string' : 'Month', 'type' : 'selection', 'selection' : [(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')], 'required':True }, + 'year' : {'string' : 'Year', 'type' : 'integer', 'required':True, 'default' : lambda *a: time.gmtime()[0]}, } class wiz_bymonth(wizard.interface): - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('print','Print Timesheet'),('end','Cancel')]} - }, - 'print': { - 'actions': [], - 'result': {'type': 'print', 'report': 'hr.timesheet.bymonth', 'state': 'end'} - } - } + states = { + 'init': { + 'actions': [], + 'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('print','Print Timesheet'),('end','Cancel')]} + }, + 'print': { + 'actions': [], + 'result': {'type': 'print', 'report': 'hr.timesheet.bymonth', 'state': 'end'} + } + } wiz_bymonth('hr.print_month') diff --git a/addons/hr/wizard/print_byweek.py b/addons/hr/wizard/print_byweek.py index 00b72f037f2..cab9bfa5584 100644 --- a/addons/hr/wizard/print_byweek.py +++ b/addons/hr/wizard/print_byweek.py @@ -32,27 +32,27 @@ import time _date_form = '''<?xml version="1.0"?> <form string="Select a time span"> - <separator string="Select a starting and a end date" colspan="4"/> - <field name="init_date"/> - <newline/> - <field name="end_date"/> + <separator string="Select a starting and a end date" colspan="4"/> + <field name="init_date"/> + <newline/> + <field name="end_date"/> </form>''' _date_fields = { - 'init_date': {'string':'Starting Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True}, - 'end_date': {'string':'Ending Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True} + 'init_date': {'string':'Starting Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True}, + 'end_date': {'string':'Ending Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True} } class wiz_byweek(wizard.interface): - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('print','Print Timesheet'),('end','Cancel') ]} - }, - 'print': { - 'actions': [], - 'result': {'type': 'print', 'report': 'hr.timesheet.allweeks', 'state':'end'} - } - } + states = { + 'init': { + 'actions': [], + 'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('print','Print Timesheet'),('end','Cancel') ]} + }, + 'print': { + 'actions': [], + 'result': {'type': 'print', 'report': 'hr.timesheet.allweeks', 'state':'end'} + } + } wiz_byweek('hr.print_week') diff --git a/addons/hr/wizard/sign_in_out.py b/addons/hr/wizard/sign_in_out.py index 70b909262a8..738a02641e1 100644 --- a/addons/hr/wizard/sign_in_out.py +++ b/addons/hr/wizard/sign_in_out.py @@ -34,155 +34,155 @@ from tools.translate import _ si_so_form ='''<?xml version="1.0"?> <form string="Sign in / Sign out"> - <separator string="You are now ready to sign in or out of the attendance follow up" colspan="4" /> - <field name="name" readonly="True" /> - <field name="state" readonly="True" /> + <separator string="You are now ready to sign in or out of the attendance follow up" colspan="4" /> + <field name="name" readonly="True" /> + <field name="state" readonly="True" /> </form>''' si_so_fields = { - 'name' : {'string' : "Employee's name", 'type':'char', 'required':True, 'readonly':True}, - 'state' : {'string' : "Current state", 'type' : 'char', 'required' : True, 'readonly': True}, + 'name' : {'string' : "Employee's name", 'type':'char', 'required':True, 'readonly':True}, + 'state' : {'string' : "Current state", 'type' : 'char', 'required' : True, 'readonly': True}, } si_form = '''<?xml version="1.0" ?> <form string="Sign in status"> - <seperator string="This is the status of your sign in request. Check it out maybe you were already signed in." colspan="4" /> - <field name="success" readonly="True" /> + <seperator string="This is the status of your sign in request. Check it out maybe you were already signed in." colspan="4" /> + <field name="success" readonly="True" /> </form>''' si_fields = { - 'success' : {'string' : "Sign in's status", 'type' : 'char', 'required' : True, 'readonly' : True}, + 'success' : {'string' : "Sign in's status", 'type' : 'char', 'required' : True, 'readonly' : True}, } so_form = '''<?xml version="1.0" ?> <form string="Sign in status"> - <seperator string="This is the status of your sign out request. Check it out maybe you were already signed out." colspan="4" /> - <field name="success" readonly="True" /> + <seperator string="This is the status of your sign out request. Check it out maybe you were already signed out." colspan="4" /> + <field name="success" readonly="True" /> </for>''' so_fields = { - 'success' : {'string' : "Sign out's status", 'type' : 'char', 'required' : True, 'readonly' : True}, + 'success' : {'string' : "Sign out's status", 'type' : 'char', 'required' : True, 'readonly' : True}, } def _get_empid(self, cr, uid, data, context): - service = netsvc.LocalService('object_proxy') - emp_id = service.execute(cr.dbname, uid, 'hr.employee', 'search', [('user_id', '=', uid)]) - if emp_id: - employee = service.execute(cr.dbname, uid, 'hr.employee', 'read', emp_id)[0] - return {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0]} - return {} + service = netsvc.LocalService('object_proxy') + emp_id = service.execute(cr.dbname, uid, 'hr.employee', 'search', [('user_id', '=', uid)]) + if emp_id: + employee = service.execute(cr.dbname, uid, 'hr.employee', 'read', emp_id)[0] + return {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0]} + return {} 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 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', - 'employee_id': emp_id - }) - 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} + 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'): + 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', + 'employee_id': emp_id + }) + 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} 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'): - 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]) - except: - raise wizard.except_wizard(_('UserError'), _('A sign-out must be right after a sign-in !')) - - return {'success' : success} + 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'): + 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]) + except: + raise wizard.except_wizard(_('UserError'), _('A sign-out must be right after a sign-in !')) + + return {'success' : success} so_ask_form ='''<?xml version="1.0"?> <form string="Sign in / Sign out"> - <separator string="You did not signed out the last time. Please enter the date and time you signed out." colspan="4" /> - <field name="name" readonly="True" /> - <field name="last_time" /> + <separator string="You did not signed out the last time. Please enter the date and time you signed out." colspan="4" /> + <field name="name" readonly="True" /> + <field name="last_time" /> </form>''' so_ask_fields = { - 'name' : {'string' : "Employee's name", 'type':'char', 'required':True, 'readonly':True}, - 'last_time' : {'string' : "Your last sign out", 'type' : 'datetime', 'required' : True}, + 'name' : {'string' : "Employee's name", 'type':'char', 'required':True, 'readonly':True}, + 'last_time' : {'string' : "Your last sign out", 'type' : 'datetime', 'required' : True}, } def _si_check(self, cr, uid, data, context): - states = {True : 'si', False: 'si_ask_so'} - 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') - last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id) - if last_att: - last_att = last_att[0] - cond = not last_att or last_att['action'] == 'sign_out' - return states[cond] + states = {True : 'si', False: 'si_ask_so'} + 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') + last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id) + if last_att: + last_att = last_att[0] + cond = not last_att or last_att['action'] == 'sign_out' + return states[cond] si_ask_form ='''<?xml version="1.0"?> <form string="Sign in / Sign out"> - <separator string="You did not signed in the last time. Please enter the date and time you signed in." colspan="4" /> - <field name="name" readonly="True" /> - <field name="last_time" /> + <separator string="You did not signed in the last time. Please enter the date and time you signed in." colspan="4" /> + <field name="name" readonly="True" /> + <field name="last_time" /> </form>''' si_ask_fields = { - 'name' : {'string' : "Employee's name", 'type':'char', 'required':True, 'readonly':True}, - 'last_time' : {'string' : "Your last sign in", 'type' : 'datetime', 'required' : True}, + 'name' : {'string' : "Employee's name", 'type':'char', 'required':True, 'readonly':True}, + 'last_time' : {'string' : "Your last sign in", 'type' : 'datetime', 'required' : True}, } 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') - last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id) - if last_att: - last_att = last_att[0] - cond = last_att and last_att['action'] == 'sign_in' - return states[cond] + 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') + last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id) + if last_att: + last_att = last_att[0] + cond = last_att and last_att['action'] == 'sign_in' + return states[cond] class wiz_si_so(wizard.interface): - states = { - 'init' : { - 'actions' : [_get_empid], - 'result' : {'type' : 'form', 'arch' : si_so_form, 'fields' : si_so_fields, 'state' : [('end', 'Cancel'),('si_test', 'Sign in'),('so_test', 'Sign out')] } - }, - 'si_test' : { - 'actions' : [], - 'result' : {'type' : 'choice', 'next_state': _si_check} - }, - 'si_ask_so' : { - 'actions' : [], - 'result' : {'type' : 'form', 'arch' : so_ask_form, 'fields' : so_ask_fields, 'state' : [('end', 'Cancel'),('si', 'Sign in') ] } - }, - 'si' : { - 'actions' : [_sign_in], - 'result' : {'type' : 'state', 'state':'end'} - }, - 'so_test' : { - 'actions' : [], - 'result' : {'type' : 'choice', 'next_state': _so_check } - }, - 'so_ask_si' : { - 'actions' : [], - 'result' : {'type' : 'form', 'arch' : si_ask_form, 'fields' : si_ask_fields, 'state' : [('end', 'Cancel'),('so', 'Sign out')] } - }, - 'so' : { - 'actions' : [_sign_out], - 'result' : {'type' : 'state', 'state':'end'} - }, - } + states = { + 'init' : { + 'actions' : [_get_empid], + 'result' : {'type' : 'form', 'arch' : si_so_form, 'fields' : si_so_fields, 'state' : [('end', 'Cancel'),('si_test', 'Sign in'),('so_test', 'Sign out')] } + }, + 'si_test' : { + 'actions' : [], + 'result' : {'type' : 'choice', 'next_state': _si_check} + }, + 'si_ask_so' : { + 'actions' : [], + 'result' : {'type' : 'form', 'arch' : so_ask_form, 'fields' : so_ask_fields, 'state' : [('end', 'Cancel'),('si', 'Sign in') ] } + }, + 'si' : { + 'actions' : [_sign_in], + 'result' : {'type' : 'state', 'state':'end'} + }, + 'so_test' : { + 'actions' : [], + 'result' : {'type' : 'choice', 'next_state': _so_check } + }, + 'so_ask_si' : { + 'actions' : [], + 'result' : {'type' : 'form', 'arch' : si_ask_form, 'fields' : si_ask_fields, 'state' : [('end', 'Cancel'),('so', 'Sign out')] } + }, + 'so' : { + 'actions' : [_sign_out], + 'result' : {'type' : 'state', 'state':'end'} + }, + } wiz_si_so('hr.si_so') # vim:noexpandtab:tw=0 |
