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

Proposed by Nicolas Bessi - Camptocamp
Status: Merged
Merged at revision: 9296
Proposed branch: lp:~camptocamp/ocb-addons/7.0-fix-1188593
Merge into: lp:ocb-addons
Diff against target: 34 lines (+12/-3)
1 file modified
hr_timesheet_sheet/hr_timesheet_sheet.py (+12/-3)
To merge this branch: bzr merge lp:~camptocamp/ocb-addons/7.0-fix-1188593
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) Approve
Stefan Rijnhart (Opener) Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+168064@code.launchpad.net

Description of the change

fix bug 1188593
timesheet sheet name_search now support monthly and daily timesheet range

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

#11, #14 Put the strings themselves into _() and remove it from #26, this way they are properly extracted.

What I'd prefer: Put the whole string into a translated format string, like _('Week %U') and feed that to strftime (label can be dropped then). We shouldn't make assumptions on how other languages handle that.

review: Needs Fixing
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Thanks for review I just committed the fixes.

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

LGMT

review: Approve
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve

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-17 07:11:28 +0000
3+++ hr_timesheet_sheet/hr_timesheet_sheet.py 2013-06-17 12:35:40 +0000
4@@ -221,13 +221,23 @@
5 return True
6
7 def name_get(self, cr, uid, ids, context=None):
8+ user = self.pool['res.users'].browse(cr, uid, uid, context=context)
9+ tm_range = user.company_id.timesheet_range or 'month'
10+ if tm_range == 'week':
11+ tformat = _('Week %U')
12+ elif tm_range == 'month':
13+ tformat = _('Month %m')
14+ elif tm_range == 'day':
15+ tformat = user.lang.date_format if user.lang.date_format else '%Y-%m-%d'
16+ else:
17+ raise ValueError(_('Unsupported timesheet range: %s') % tm_range)
18 if not ids:
19 return []
20 if isinstance(ids, (long, int)):
21 ids = [ids]
22- return [(r['id'], _('Week ')+datetime.strptime(r['date_from'], '%Y-%m-%d').strftime('%U')) \
23+ return [(r['id'], datetime.strptime(r['date_from'], '%Y-%m-%d').strftime(tformat))
24 for r in self.read(cr, uid, ids, ['date_from'],
25- context=context, load='_classic_write')]
26+ context=context, load='_classic_write')]
27
28 def unlink(self, cr, uid, ids, context=None):
29 sheets = self.read(cr, uid, ids, ['state','total_attendance'], context=context)
30@@ -578,4 +588,3 @@
31 res_company()
32
33 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
34-