+ 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 cannot duplicate a timesheet !'))
+
+ def create(self, cr, uid, vals, *args, **argv):
+ if 'employee_id' in vals:
+ if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).user_id:
+ raise osv.except_osv(_('Error !'), _('You cannot create a timesheet for an employee that does not have any user defined !'))
+ return super(hr_timesheet_sheet, self).create(cr, uid, vals, *args, **argv)
+
+ def write(self, cr, uid, ids, vals, *args, **argv):
+ if 'employee_id' in vals:
+ new_user_id = self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).user_id.id or False
+ if not new_user_id:
+ raise osv.except_osv(_('Error !'), _('You cannot create a timesheet for an employee that does not have any user defined !'))
+ if not self._sheet_date(cr, uid, ids, forced_user_id=new_user_id):
+ raise osv.except_osv(_('Error !'), _('You can not have 2 timesheets that overlaps !\nPlease use the menu \'My Current Timesheet\' to avoid this problem.'))
+ return super(hr_timesheet_sheet, self).write(cr, uid, ids, vals, *args, **argv)
+
+ def button_confirm(self, cr, uid, ids, context=None):
+ for sheet in self.browse(cr, uid, ids, context=context):
+ self.check_employee_attendance_state(cr, uid, sheet.id, context)