Ravi Gohil (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-579812-rgo into 
lp:openobject-addons/6.1.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-579812-rgo/+merge/128489

Hello,

When you create a meeting for all day, time in start date and end date are not 
set to 00:00:00 or to 12:00:00 AM.

This fixes this issue, backported from trunk. Kindly review it.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-579812-rgo/+merge/128489
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-579812-rgo.
=== modified file 'base_calendar/base_calendar.py'
--- base_calendar/base_calendar.py	2012-03-05 14:35:54 +0000
+++ base_calendar/base_calendar.py	2012-10-08 13:24:39 +0000
@@ -942,16 +942,19 @@
             duration = 1.00
             value['duration'] = duration
 
+        start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
         if allday: # For all day event
-            value = {'duration': 24.0}
             duration = 24.0
-            if start_date:
-                start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
-                start_date = datetime.strftime(datetime(start.year, start.month, start.day, 0,0,0), "%Y-%m-%d %H:%M:%S")
-                value['date'] = start_date
-
-
-        start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
+            value['duration'] = duration
+            # change start_date's time to 00:00:00 in the user's timezone
+            user = self.pool.get('res.users').browse(cr, uid, uid)
+            tz = pytz.timezone(user.context_tz) if user.context_tz else pytz.utc
+            start = pytz.utc.localize(start).astimezone(tz)     # convert start in user's timezone
+            start = start.replace(hour=0, minute=0, second=0)   # change start's time to 00:00:00
+            start = start.astimezone(pytz.utc)                  # convert start back to utc
+            start_date = start.strftime("%Y-%m-%d %H:%M:%S")
+            value['date'] = start_date
+        
         if end_date and not duration:
             end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S")
             diff = end - start

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to