From 6b83b67f60e6336b8b2e2fdb809e35c1e1b7a3cb Mon Sep 17 00:00:00 2001 From: skh Date: Fri, 15 Apr 2011 14:19:06 +0530 Subject: [PATCH 1/3] [FIX] Adding working time in a confirmed timesheet lp bug: https://launchpad.net/bugs/760493 fixed bzr revid: skh@tinyerp.com-20110415084906-j70rij3nfvr77cn3 --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 23ab63247e5..c65dc810c3e 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -481,6 +481,19 @@ class hr_timesheet_line(osv.osv): 'date': _get_default_date, } + def _check_sheet_state(self, cr, uid, ids, context=None): + if context is None: + context = {} + line = self.browse(cr, uid, ids, context=context) + for timesheet in line: + if timesheet.sheet_id and timesheet.sheet_id.state not in ('draft', 'new'): + return False + return True + + _constraints = [ + (_check_sheet_state, 'You can not modify an entry in a confirmed timesheet !.', ['state']), + ] + def create(self, cr, uid, vals, *args, **kwargs): if vals.get('sheet_id', False): ts = self.pool.get('hr_timesheet_sheet.sheet').browse(cr, uid, vals['sheet_id']) From 75c16a19ccb94283f0897421db4fb5583cee2200 Mon Sep 17 00:00:00 2001 From: skh Date: Fri, 15 Apr 2011 14:44:28 +0530 Subject: [PATCH 2/3] [FIX] Adding working time in a confirmed timesheet lp bug: https://launchpad.net/bugs/760493 fixed bzr revid: skh@tinyerp.com-20110415091428-r9rm44mkdnjiwp9x --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index c65dc810c3e..4e5d8331441 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -484,14 +484,13 @@ class hr_timesheet_line(osv.osv): def _check_sheet_state(self, cr, uid, ids, context=None): if context is None: context = {} - line = self.browse(cr, uid, ids, context=context) - for timesheet in line: - if timesheet.sheet_id and timesheet.sheet_id.state not in ('draft', 'new'): + for timesheet_line in self.browse(cr, uid, ids, context=context): + if timesheet_line.sheet_id and timesheet_line.sheet_id.state not in ('draft', 'new'): return False return True _constraints = [ - (_check_sheet_state, 'You can not modify an entry in a confirmed timesheet !.', ['state']), + (_check_sheet_state, 'You can not modify an entry in a Confirmed/Done timesheet !.', ['state']), ] def create(self, cr, uid, vals, *args, **kwargs): From c2719f0f8cd984db73cb9ca58907c7a53f7c700a Mon Sep 17 00:00:00 2001 From: skh Date: Fri, 15 Apr 2011 15:35:34 +0530 Subject: [PATCH 3/3] [FIX] Adding working time in a confirmed timesheet lp bug: https://launchpad.net/bugs/760493 fixed bzr revid: skh@tinyerp.com-20110415100534-g823ifs3sa7ufz4l --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 4e5d8331441..6fca2b7e23e 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -493,21 +493,10 @@ class hr_timesheet_line(osv.osv): (_check_sheet_state, 'You can not modify an entry in a Confirmed/Done timesheet !.', ['state']), ] - def create(self, cr, uid, vals, *args, **kwargs): - if vals.get('sheet_id', False): - ts = self.pool.get('hr_timesheet_sheet.sheet').browse(cr, uid, vals['sheet_id']) - if not ts.state in ('draft', 'new'): - raise osv.except_osv(_('Error !'), _('You can not modify an entry in a confirmed timesheet !')) - return super(hr_timesheet_line,self).create(cr, uid, vals, *args, **kwargs) - def unlink(self, cr, uid, ids, *args, **kwargs): self._check(cr, uid, ids) return super(hr_timesheet_line,self).unlink(cr, uid, ids,*args, **kwargs) - def write(self, cr, uid, ids, *args, **kwargs): - self._check(cr, uid, ids) - return super(hr_timesheet_line,self).write(cr, uid, ids,*args, **kwargs) - 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'):