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

Proposed by Nicolas Bessi - Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/7.0-fix-1188593
Merge into: lp:openobject-addons/7.0
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/openobject-addons/7.0-fix-1188593
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+168066@code.launchpad.net

Description of the change

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

To post a comment you must log in.
9206. By Nicolas Bessi - Camptocamp on 2013-06-17

[MRG] fix of hr_timesheet_sheet translation management name_get

Unmerged revisions

9206. By Nicolas Bessi - Camptocamp on 2013-06-17

[MRG] fix of hr_timesheet_sheet translation management name_get

9205. By Nicolas Bessi - Camptocamp on 2013-06-07

[FIX] bug 1188593 name_search now support monthly and daily timesheet range

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-17 12:38:29 +0000
4@@ -198,13 +198,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@@ -555,4 +565,3 @@
31 res_company()
32
33 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
34-