From 3199d71f923a95f692c29f379ccabd7ed3665187 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Tue, 20 Jan 2009 19:51:08 +0100 Subject: [PATCH 1/2] [FIX] hr_timesheet_sheet: The name and the user are readonly when the state is confirmed or done lp bug: https://launchpad.net/bugs/319163 fixed bzr revid: stephane@tinyerp.com-20090120185108-76awzargwf81rfcw --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 83ce4f5168f..839f90ca17f 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -205,8 +205,10 @@ class hr_timesheet_sheet(osv.osv): return True _columns = { - 'name': fields.char('Description', size=64, select=1), - 'user_id': fields.many2one('res.users', 'User', required=True, select=1), + 'name': fields.char('Description', size=64, select=1, + states={'confirm':[('readonly', True)], 'done':[('readonly', True)]}), + 'user_id': 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)]}), 'date_current': fields.date('Current date', required=True), From 618cc03cca630a5f5a4f6a810d85f709897ace46 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Tue, 20 Jan 2009 21:32:58 +0100 Subject: [PATCH 2/2] [FIX] hr_timesheet_sheet - Can't remove a confirmed timesheet lp bug: https://launchpad.net/bugs/319186 fixed bzr revid: stephane@tinyerp.com-20090120203258-eegloe0sqmygrwcj --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 839f90ca17f..4ca8400aaaf 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -299,6 +299,12 @@ class hr_timesheet_sheet(osv.osv): for r in self.read(cr, uid, ids, ['date_from', 'date_to'], context, load='_classic_write')] + def unlink(self, cr, uid, ids, context=None): + sheets = self.read(cr, uid, ids, ['state']) + if any(s['state'] in ('confirm', 'done') for s in sheets): + raise osv.except_osv(_('Invalid action !'), _('Cannot delete Sheet(s) which are already confirmed !')) + return super(hr_timesheet_sheet, self).unlink(cr, uid, ids, context=context) + hr_timesheet_sheet()