[FIX] hr_timesheet_sheet : timesheet should only be confirmed when no. of sign in entries equal to sign out

bzr revid: jvo@tinyerp.com-20100811155857-fdsy4zuntywb7eda
This commit is contained in:
Jay (Open ERP) 2010-08-11 21:28:57 +05:30
parent b7030c4dc9
commit 53411e0686
1 changed files with 10 additions and 1 deletions

View File

@ -147,14 +147,23 @@ class hr_timesheet_sheet(osv.osv):
sheet_id = link_emp[emp.id]
result[sheet_id] = emp.state
return result
def check_employee_attendance_state(self, cr, uid, sheet_id, context=None):
ids_signin = self.pool.get('hr.attendance').search(cr,uid,[('sheet_id', '=', sheet_id),('action','=','sign_in')])
ids_signout = self.pool.get('hr.attendance').search(cr,uid,[('sheet_id', '=', sheet_id),('action','=','sign_out')])
if len(ids_signin) != len(ids_signout):
raise osv.except_osv(('Warning !'),_('The timesheet cannot be validated as it does not contain equal no. of sign ins and sign outs!'))
return True
def copy(self, cr, uid, ids, *args, **argv):
raise osv.except_osv(_('Error !'), _('You can not duplicate a timesheet !'))
raise osv.except_osv(_('Error !'), _('You cannot duplicate a timesheet !'))
def button_confirm(self, cr, uid, ids, context=None):
if context is None:
context = {}
for sheet in self.browse(cr, uid, ids, context=context):
self.check_employee_attendance_state(cr, uid, sheet.id, context)
di = sheet.user_id.company_id.timesheet_max_difference
if (abs(sheet.total_difference) < di) or not di:
wf_service = netsvc.LocalService("workflow")