Merge lp:~openerp-dev/openobject-addons/7.0-opw-584793-cbi into lp:openobject-addons/7.0

Proposed by Chris Biersbach (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-584793-cbi
Merge into: lp:openobject-addons/7.0
Diff against target: 64 lines (+10/-8)
1 file modified
base_calendar/base_calendar.py (+10/-8)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-584793-cbi
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+149067@code.launchpad.net

Description of the change

The issue: When using Meetings, no reminders are sent.

The reason: Reminders use the "display" action type, which is not implemented.

The fix: I changed the action type to "email". I also fixed some other small timezone and display bugs in the reminder email as well as in the invitation email. Both invitation and reminder should now correctly contain the meeting start time in the appropriate timezone. The reminder email no longer contains "False" when there is no event description.

In addition, reminders were triggered as soon as the meeting reminder scheduler ran for the next time. This is not correct, because it renders the settings (f.e. 30 minutes before) useless. I changed the behavior to take the settings into account (I test whether or not we are actually inside "30 minutes before").

To post a comment you must log in.

Unmerged revisions

8682. By Chris Biersbach (OpenERP)

[FIX] base_calendar meeting invitations and reminders now work correctly

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_calendar/base_calendar.py'
2--- base_calendar/base_calendar.py 2012-12-28 11:18:53 +0000
3+++ base_calendar/base_calendar.py 2013-02-18 15:01:12 +0000
4@@ -514,7 +514,7 @@
5 (att2.partner_id and att2.partner_id.name) or \
6 att2.email) + ' - Status: ' + att2.state.title())
7 #dates and times are gonna be expressed in `tz` time (local timezone of the `uid`)
8- tz = context.get('tz', pytz.timezone('UTC'))
9+ tz = context.get('tz', pytz.timezone('UTC')) or 'UTC'
10 #res_obj.date and res_obj.date_deadline are in UTC in database so we use context_timestamp() to transform them in the `tz` timezone
11 date_start = fields.datetime.context_timestamp(cr, uid, datetime.strptime(res_obj.date, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context)
12 date_stop = False
13@@ -716,7 +716,7 @@
14 self.do_alarm_unlink(cr, uid, [data.id], model)
15 if basic_alarm:
16 vals = {
17- 'action': 'display',
18+ 'action': 'email',
19 'description': data.description,
20 'name': data.name,
21 'attendee_ids': [(6, 0, map(lambda x:x.id, data.attendee_ids))],
22@@ -879,13 +879,15 @@
23
24 else:
25 re_dates = [alarm.trigger_date]
26-
27- if re_dates:
28+ sent = False
29+ if re_dates and any([datetime.strptime(date, '%Y-%m-%d %H:%M:%S') <= current_datetime for date in re_dates]):
30+ sent = True
31+ date = fields.datetime.context_timestamp(cr, uid, datetime.strptime(res_obj.date, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context)
32 if alarm.action == 'email':
33 sub = '[OpenERP Reminder] %s' % (alarm.name)
34 body = """<pre>
35 Event: %s
36-Event Date: %s
37+Event Date: %s (%s)
38 Description: %s
39
40 From:
41@@ -894,7 +896,7 @@
42 ----
43 %s
44 </pre>
45-""" % (alarm.name, alarm.trigger_date, alarm.description, \
46+""" % (alarm.name, date, date.tzname(), alarm.description or '', \
47 alarm.user_id.name, alarm.user_id.signature)
48 mail_to = alarm.user_id.email
49 for att in alarm.attendee_ids:
50@@ -905,12 +907,12 @@
51 'subject': sub,
52 'body_html': body,
53 'email_to': mail_to,
54- 'email_from': tools.config.get('email_from', mail_to),
55+ 'email_from': alarm.user_id.email or tools.config.get('email_from', mail_to),
56 }
57 self.pool.get('mail.mail').create(cr, uid, vals, context=context)
58 if next_trigger_date:
59 update_vals.update({'trigger_date': next_trigger_date})
60- else:
61+ elif sent:
62 update_vals.update({'state': 'done'})
63 self.write(cr, uid, [alarm.id], update_vals)
64 return True