From 1d7120a978e043a9578cc3cf61870e6480b9712e Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 9 Feb 2015 12:24:47 +0100 Subject: [PATCH] [FIX] hr_timesheet_sheet: prevent modify activities of confirmed sheets In 7.0, prevent changes in activities of validated sheets was done thanks to the constraint _check_sheet_state. In 7.0, python constraints were checked at each write operations whatever if the fields on which the constraint is were altered or not This is no longer the case in Odoo 8.0: The constraint is checked only if the fields on which the constraint is are altered. As this specific constraint must be applied anytime, whatever the altered fields, we now do this constraint check in the "write" method. Besides, it was already the case for the unlink method. opw-627415 --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 9858b96c47b..f59bceb9a82 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -358,17 +358,11 @@ class hr_timesheet_line(osv.osv): ), } - def _check_sheet_state(self, cr, uid, ids, context=None): - if context is None: - context = {} - 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 cannot modify an entry in a Confirmed/Done timesheet !', ['state']), - ] + def write(self, cr, uid, ids, values, context=None): + if isinstance(ids, (int, long)): + ids = [ids] + self._check(cr, uid, ids) + return super(hr_timesheet_line, self).write(cr, uid, ids, values, context=context) def unlink(self, cr, uid, ids, *args, **kwargs): if isinstance(ids, (int, long)):