From d32d812812487e15cff44d74cfaf852f02f7f3c2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 22 Jun 2016 19:04:06 +0000 Subject: [PATCH] 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) --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 8b622dc9b34..ec2af26dffb 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -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)]}), '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'), @@ -332,8 +327,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 @@ -386,7 +380,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 @@ -531,7 +525,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