[IMP] hr_timesheet_sheet: sign-in and sign-out buttons on the sheet use the same attendances wizard which asks for the last sign-in/sign-out if it is missing instead of raising an error

bzr revid: guewen.baconnier@camptocamp.com-20110706074731-8v14k99lcgmipm4y
This commit is contained in:
2011-07-06 09:47:31 +02:00
parent 4a2f59cca8
commit 8bdaefd12e
@@ -245,23 +245,29 @@ class hr_timesheet_sheet(osv.osv):
self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context)
return True
def sign(self, cr, uid, ids, typ, context=None):
emp_obj = self.pool.get('hr.employee')
def check_sign(self, cr, uid, ids, typ, context=None):
sheet = self.browse(cr, uid, ids, context=context)[0]
if context is None:
context = {}
if not sheet.date_current == time.strftime('%Y-%m-%d'):
raise osv.except_osv(_('Error !'), _('You cannot sign in/sign out from an other date than today'))
emp_id = sheet.employee_id.id
context['sheet_id']=ids[0]
emp_obj.attendance_action_change(cr, uid, [emp_id], type=typ, context=context,)
return True
def sign(self, cr, uid, ids, typ, context=None):
self.check_sign(cr, uid, ids, typ, context=context)
sign_obj = self.pool.get('hr.sign.in.out')
sign_id = sign_obj.create(cr, uid, {}, context=context)
methods = {'sign_in': sign_obj.si_check,
'sign_out': sign_obj.so_check}
wizard_result = methods[typ](cr, uid, [sign_id], context=context)
if wizard_result.get('type', False) == 'ir.actions.act_window_close':
return True # ensure we do not close the main window !
wizard_result['nodestroy'] = True # do not destroy the main window !
return wizard_result
def sign_in(self, cr, uid, ids, context=None):
return self.sign(cr,uid,ids,'sign_in',context=None)
return self.sign(cr, uid, ids, 'sign_in', context=context)
def sign_out(self, cr, uid, ids, context=None):
return self.sign(cr,uid,ids,'sign_out',context=None)
return self.sign(cr, uid, ids, 'sign_out', context=context)
_columns = {
'name': fields.char('Description', size=64, select=1,