[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
This commit is contained in:
Denis Ledoux 2015-02-09 12:24:47 +01:00
parent d0518d2da3
commit 1d7120a978
1 changed files with 5 additions and 11 deletions

View File

@ -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)):