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

Requested reviews:
  Naresh(OpenERP) (nch-openerp)
Related bugs:
  Bug #1073578 in OpenERP Addons: "Timestamps in body of mail of a meeting 
invitation is wrong timezone"
  https://bugs.launchpad.net/openobject-addons/+bug/1073578

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

Hello,

Timestamps in body part of the meeting invitation email displays time in UTC 
and not in the user's timezone.

Steps to reproduce:
1) Set the timezone in user's preference,
2) Install CRM module and create a meeting and run `Invite People` wizard with 
`Send mail?` option marked.

You wont have any timezone information in invitation email contents.

This fix will consider timezone in User Preferences and will show timestamps 
with timezone information in email body.

Kindly review the fix.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-581633-rgo/+merge/134877
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-581633-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-11-19 11:44:20 +0000
@@ -204,6 +204,20 @@
 </html>
 """
 
+def set_local_timezone(obj, cr, uid, dt, context=None):
+    '''
+    This method will convert datetime in logged in user's timezone
+    dt: will be the datetime in string
+    '''
+    if len(dt) <= 10:
+        return datetime.strptime(dt, '%Y-%m-%d')
+    else:
+        tz_info = context.get('tz') or 'UTC'
+        local_tz = pytz.timezone(tz_info)
+        local_time = tools.misc.server_to_local_timestamp(dt, '%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S', tz_info)
+        event_date = local_tz.localize(datetime.strptime(local_time, '%Y-%m-%d %H:%M:%S'), is_dst=True)
+        return event_date
+
 class calendar_attendee(osv.osv):
     """
     Calendar Attendee Information
@@ -498,9 +512,11 @@
                     att_infos.append(((att2.user_id and att2.user_id.name) or \
                                  (att2.partner_id and att2.partner_id.name) or \
                                     att2.email) + ' - Status: ' + att2.state.title())
+                start_date = set_local_timezone(self, cr, uid, res_obj.date, context=context).strftime('%Y-%m-%d %I:%M:%S %p %Z')
+                end_date = res_obj.date_deadline and set_local_timezone(self, cr, uid, res_obj.date_deadline, context=context).strftime('%Y-%m-%d %I:%M:%S %p %Z') or False
                 body_vals = {'name': res_obj.name,
-                            'start_date': res_obj.date,
-                            'end_date': res_obj.date_deadline or False,
+                            'start_date': start_date,
+                            'end_date': end_date,
                             'description': res_obj.description or '-',
                             'location': res_obj.location or '-',
                             'attendees': '<br>'.join(att_infos),
@@ -879,6 +895,7 @@
 
                 if alarm.action == 'email':
                     sub = '[Openobject Reminder] %s' % (alarm.name)
+                    event = set_local_timezone(self, cr, uid, alarm.event_date, context=context).strftime('%Y-%m-%d %I:%M:%S %p %Z')
                     body = """
 Event: %s
 Event Date: %s
@@ -890,7 +907,7 @@
 ----
 %s
 
-"""  % (alarm.name, alarm.trigger_date, alarm.description, \
+"""  % (alarm.name, event, alarm.description, \
                         alarm.user_id.name, alarm.user_id.signature)
                     mail_to = [alarm.user_id.user_email]
                     for att in alarm.attendee_ids:

=== modified file 'base_calendar/wizard/base_calendar_invite_attendee.py'
--- base_calendar/wizard/base_calendar_invite_attendee.py	2012-01-31 13:36:57 +0000
+++ base_calendar/wizard/base_calendar_invite_attendee.py	2012-11-19 11:44:20 +0000
@@ -142,7 +142,7 @@
                                        self._columns['type'].selection))
                     raise osv.except_osv(_('Error!'), _("%s must have an email  address to send mail") %(name[0]))
                 att_obj._send_mail(cr, uid, attendees, mail_to, \
-                       email_from = current_user.user_email or tools.config.get('email_from', False))
+                       email_from = current_user.user_email or tools.config.get('email_from', False), context=context)
 
         return {'type': 'ir.actions.act_window_close'}
 

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to