Merge lp:~camptocamp/openobject-addons/7.0-fix-1190934 into lp:openobject-addons/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/7.0-fix-1190934
Merge into: lp:openobject-addons/7.0
Diff against target: 27 lines (+14/-3)
1 file modified
hr_timesheet_sheet/hr_timesheet_sheet.py (+14/-3)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/7.0-fix-1190934
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+169374@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

This is a quick fix maybe not the best choice, perhaps a new constraint to check sheet_id and date match would do a part of the job?

Unmerged revisions

9238. By Yannick Vaucher @ Camptocamp on 2013-06-14

[FIX] hr_timesheet_sheet - redefine _check_sheet_state to make sur it controls the right timesheet_sheet to make sure it isn't possible to timesheet on a already confirmed or closed timesheet_sheet

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_timesheet_sheet/hr_timesheet_sheet.py'
2--- hr_timesheet_sheet/hr_timesheet_sheet.py 2013-05-08 08:59:38 +0000
3+++ hr_timesheet_sheet/hr_timesheet_sheet.py 2013-06-14 09:56:45 +0000
4@@ -306,9 +306,20 @@
5 def _check_sheet_state(self, cr, uid, ids, context=None):
6 if context is None:
7 context = {}
8- for timesheet_line in self.browse(cr, uid, ids, context=context):
9- if timesheet_line.sheet_id and timesheet_line.sheet_id.state not in ('draft', 'new'):
10- return False
11+ ts_sheet_obj = self.pool.get('hr_timesheet_sheet.sheet')
12+ # When a timesheet_line is created from view tree of
13+ # hr.analytic.timesheet sheet_id is not defined at this stage
14+ # here we check the state of the timesheet for the given date
15+ # Furthermore we don't want a default sheet_id allowing to bypass
16+ # the check so we recompute all sheet_ids
17+ sheet_ids = self._sheet(cr ,uid, ids, False, False, context=context)
18+ for ts_line_id, sheet in sheet_ids.iteritems():
19+
20+ if sheet:
21+ ts_sheet = ts_sheet_obj.browse(cr, uid, sheet[0], context=context)
22+ if ts_sheet.state not in ('draft', 'new'):
23+ return False
24+
25 return True
26
27 _constraints = [