Merge lp:~openerp-dev/openobject-addons/7.0-opw-599537-rha into lp:openobject-addons/7.0

Proposed by Rifakat Husen (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-599537-rha
Merge into: lp:openobject-addons/7.0
Diff against target: 23 lines (+3/-3)
1 file modified
event/event.py (+3/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-599537-rha
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+193545@code.launchpad.net

Description of the change

Fix date problem in the name_get() of event registration,
it was not taking care the user's timezone and was directly putting date from db which is actually a UTC value.

Problem:
- create an event record and fill start date on 12 AM i.e. 31-10-2013 00:00:00,
  this will save UTC date value in the table which is 30-10-2013 18:30:00
- when you try to create a registration record and try to choose event.
  a name_get() is overidden and shows "event name (date)" where this date is directly fetched from table which
  UTC value.
- In fact we need to convert this date to user's timezone and then use in name_get() result so that this will
  show correct date.

To post a comment you must log in.

Unmerged revisions

9542. By Rifakat Husen (OpenERP)

[FIX] event: fix date problem in the name_get() of event registration,
it was not taking care the user's timezone and was directly putting date from db which is actually a UTC value

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'event/event.py'
2--- event/event.py 2012-12-21 16:48:08 +0000
3+++ event/event.py 2013-11-01 05:44:08 +0000
4@@ -22,7 +22,7 @@
5 from datetime import datetime, timedelta
6 from openerp.osv import fields, osv
7 from openerp.tools.translate import _
8-from openerp import SUPERUSER_ID
9+from openerp import SUPERUSER_ID, tools
10
11 class event_type(osv.osv):
12 """ Event Type """
13@@ -59,8 +59,8 @@
14
15 res = []
16 for record in self.browse(cr, uid, ids, context=context):
17- date = record.date_begin.split(" ")[0]
18- date_end = record.date_end.split(" ")[0]
19+ date = str(fields.datetime.context_timestamp(cr, uid, datetime.strptime(record.date_begin, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context)).split(" ")[0]
20+ date_end = str(fields.datetime.context_timestamp(cr, uid, datetime.strptime(record.date_end, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context)).split(" ")[0]
21 if date != date_end:
22 date += ' - ' + date_end
23 display_name = record.name + ' (' + date + ')'