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

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 9453
Proposed branch: lp:~camptocamp/ocb-addons/7.0-fix-1190934
Merge into: lp:ocb-addons
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/ocb-addons/7.0-fix-1190934
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Guewen Baconnier @ Camptocamp Approve
Review via email: mp+177414@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) :
review: Approve
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

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-06-24 10:31:45 +0000
3+++ hr_timesheet_sheet/hr_timesheet_sheet.py 2013-07-29 15:19:35 +0000
4@@ -339,9 +339,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 = [