← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~andrei-levin/ocb-addons/6.1 into lp:ocb-addons/6.1

 

Andrei Levin has proposed merging lp:~andrei-levin/ocb-addons/6.1 into lp:ocb-addons/6.1.

Requested reviews:
  OpenERP Community Backports (ocb)

For more details, see:
https://code.launchpad.net/~andrei-levin/ocb-addons/6.1/+merge/222862

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.

The FIX is created by Ravi Gohil

-- 
https://code.launchpad.net/~andrei-levin/ocb-addons/6.1/+merge/222862
Your team OpenERP Community Backports is requested to review the proposed merge of lp:~andrei-levin/ocb-addons/6.1 into lp:ocb-addons/6.1.
=== modified file '.bzrignore'
--- .bzrignore	2011-01-14 00:11:01 +0000
+++ .bzrignore	2014-06-11 19:16:38 +0000
@@ -1,1 +1,2 @@
 .*
+*.orig

=== modified file 'base_calendar/__openerp__.py'
--- base_calendar/__openerp__.py	2012-01-31 13:36:57 +0000
+++ base_calendar/__openerp__.py	2014-06-11 19:16:38 +0000
@@ -21,7 +21,7 @@
 
 {
     "name": "Calendar Layer",
-    "version": "1.0",
+    "version": "1.0.1",
     "depends": ["base", "mail"],
     'complexity': "easy",
     'description': """

=== modified file 'base_calendar/base_calendar.py'
--- base_calendar/base_calendar.py	2013-09-10 15:12:35 +0000
+++ base_calendar/base_calendar.py	2014-06-11 19:16:38 +0000
@@ -208,6 +208,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
@@ -502,9 +516,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),
@@ -883,6 +899,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
@@ -894,7 +911,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	2014-06-11 19:16:38 +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'}
 


Follow ups