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:
parent
6088f138d5
commit
12e9a7123a
|
@ -166,12 +166,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)]}),
|
||||
'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)]}),
|
||||
'timesheet_ids' : fields.one2many('hr.analytic.timesheet', 'sheet_id',
|
||||
'Timesheet lines',
|
||||
readonly=True, states={
|
||||
'draft': [('readonly', False)],
|
||||
'new': [('readonly', False)]}
|
||||
),
|
||||
'timesheet_ids' : fields.one2many('hr.analytic.timesheet', 'sheet_id', 'Timesheet lines'),
|
||||
'attendances_ids' : fields.one2many('hr.attendance', 'sheet_id', 'Attendances'),
|
||||
'state' : fields.selection([
|
||||
('new', 'New'),
|
||||
|
@ -336,8 +331,7 @@ class hr_timesheet_line(osv.osv):
|
|||
for ts_line in self.browse(cursor, user, ids, context=context):
|
||||
sheet_ids = sheet_obj.search(cursor, user,
|
||||
[('date_to', '>=', ts_line.date), ('date_from', '<=', ts_line.date),
|
||||
('employee_id.user_id', '=', ts_line.user_id.id),
|
||||
('state', 'in', ['draft', 'new'])],
|
||||
('employee_id.user_id', '=', ts_line.user_id.id)],
|
||||
context=context)
|
||||
if sheet_ids:
|
||||
# [0] because only one sheet possible for an employee between 2 dates
|
||||
|
@ -390,7 +384,7 @@ class hr_timesheet_line(osv.osv):
|
|||
|
||||
def _check(self, 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.'))
|
||||
return True
|
||||
|
||||
|
@ -535,7 +529,7 @@ class hr_attendance(osv.osv):
|
|||
|
||||
def _check(self, 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'))
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue