Allow HR managers to modify even confirmed time sheets

This is particularly useful in case the "Invoicable" attribute
was not set correctly by the employee (who may even not know if
his work is invoicable to a customer or not)
This commit is contained in:
Your Name 2016-06-22 19:04:06 +00:00
parent 7b0d707417
commit d32d812812
1 changed files with 4 additions and 10 deletions

View File

@ -162,12 +162,7 @@ class hr_timesheet_sheet(osv.osv):
'user_id': fields.related('employee_id', 'user_id', type="many2one", relation="res.users", store=True, string="User", required=False, readonly=True),#fields.many2one('res.users', 'User', required=True, select=1, states={'confirm':[('readonly', True)], 'done':[('readonly', True)]}), 'user_id': fields.related('employee_id', 'user_id', type="many2one", relation="res.users", store=True, string="User", required=False, readonly=True),#fields.many2one('res.users', 'User', required=True, select=1, states={'confirm':[('readonly', True)], 'done':[('readonly', True)]}),
'date_from': fields.date('Date from', required=True, select=1, readonly=True, states={'new':[('readonly', False)]}), 'date_from': fields.date('Date from', required=True, select=1, readonly=True, states={'new':[('readonly', False)]}),
'date_to': fields.date('Date to', required=True, select=1, readonly=True, states={'new':[('readonly', False)]}), 'date_to': fields.date('Date to', required=True, select=1, readonly=True, states={'new':[('readonly', False)]}),
'timesheet_ids' : fields.one2many('hr.analytic.timesheet', 'sheet_id', 'timesheet_ids' : fields.one2many('hr.analytic.timesheet', 'sheet_id', 'Timesheet lines'),
'Timesheet lines',
readonly=True, states={
'draft': [('readonly', False)],
'new': [('readonly', False)]}
),
'attendances_ids' : fields.one2many('hr.attendance', 'sheet_id', 'Attendances'), 'attendances_ids' : fields.one2many('hr.attendance', 'sheet_id', 'Attendances'),
'state' : fields.selection([ 'state' : fields.selection([
('new', 'New'), ('new', 'New'),
@ -332,8 +327,7 @@ class hr_timesheet_line(osv.osv):
for ts_line in self.browse(cursor, user, ids, context=context): for ts_line in self.browse(cursor, user, ids, context=context):
sheet_ids = sheet_obj.search(cursor, user, sheet_ids = sheet_obj.search(cursor, user,
[('date_to', '>=', ts_line.date), ('date_from', '<=', ts_line.date), [('date_to', '>=', ts_line.date), ('date_from', '<=', ts_line.date),
('employee_id.user_id', '=', ts_line.user_id.id), ('employee_id.user_id', '=', ts_line.user_id.id)],
('state', 'in', ['draft', 'new'])],
context=context) context=context)
if sheet_ids: if sheet_ids:
# [0] because only one sheet possible for an employee between 2 dates # [0] because only one sheet possible for an employee between 2 dates
@ -386,7 +380,7 @@ class hr_timesheet_line(osv.osv):
def _check(self, cr, uid, ids): def _check(self, cr, uid, ids):
for att in self.browse(cr, uid, ids): for att in self.browse(cr, uid, ids):
if att.sheet_id and att.sheet_id.state not in ('draft', 'new'): if att.sheet_id and att.sheet_id.state not in ('draft', 'new') and not self.pool['res.users'].has_group(cr, uid, 'base.group_hr_manager'):
raise osv.except_osv(_('Error!'), _('You cannot modify an entry in a confirmed timesheet.')) raise osv.except_osv(_('Error!'), _('You cannot modify an entry in a confirmed timesheet.'))
return True return True
@ -531,7 +525,7 @@ class hr_attendance(osv.osv):
def _check(self, cr, uid, ids): def _check(self, cr, uid, ids):
for att in self.browse(cr, uid, ids): for att in self.browse(cr, uid, ids):
if att.sheet_id and att.sheet_id.state not in ('draft', 'new'): if att.sheet_id and att.sheet_id.state not in ('draft', 'new') and not self.pool['res.users'].has_group(cr, uid, 'base.group_hr_manager'):
raise osv.except_osv(_('Error!'), _('You cannot modify an entry in a confirmed timesheet')) raise osv.except_osv(_('Error!'), _('You cannot modify an entry in a confirmed timesheet'))
return True return True