diff options
| author | Achraf (abz) <abz@odoo.com> | 2020-10-20 15:01:00 +0000 |
|---|---|---|
| committer | Achraf (abz) <abz@odoo.com> | 2020-10-20 15:08:23 +0000 |
| commit | 3b1df8f57e0cd342fe7f9ff7bd34100b2c821569 (patch) | |
| tree | d2371b451f27b7bbb124717a2660fe2acda2a4f1 | |
| parent | 99702e109f661dc5d705a3337c7213a2b5f404b6 (diff) | |
[FIX] calendar: Dont send mail to attendees when the event date is past
Issue
- Install "Calender"
- Install "Google Calendar"
- Try to sync google in "Calendar"
Every created events will trigger the sending mail to attendees
even if the event date is past
Cause
'events' was not filtered
Solution
Filter 'events' to get all the events that have not yet happened
opw-2358123
closes odoo/odoo#60379
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
| -rw-r--r-- | addons/calendar/models/calendar_event.py | 2 | ||||
| -rw-r--r-- | addons/calendar/tests/test_calendar.py | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/addons/calendar/models/calendar_event.py b/addons/calendar/models/calendar_event.py index f628558ae99..d28f1c308c4 100644 --- a/addons/calendar/models/calendar_event.py +++ b/addons/calendar/models/calendar_event.py @@ -720,7 +720,7 @@ class Meeting(models.Model): detached_events = event._apply_recurrence_values(recurrence_values) detached_events.active = False - events.attendee_ids._send_mail_to_attendees('calendar.calendar_template_meeting_invitation') + events.filtered(lambda event: event.start > fields.Datetime.now()).attendee_ids._send_mail_to_attendees('calendar.calendar_template_meeting_invitation') events._sync_activities(fields={f for vals in vals_list for f in vals.keys() }) # Notify attendees if there is an alarm on the created event, as it might have changed their diff --git a/addons/calendar/tests/test_calendar.py b/addons/calendar/tests/test_calendar.py index ab0f29752a2..a7a0988b4c0 100644 --- a/addons/calendar/tests/test_calendar.py +++ b/addons/calendar/tests/test_calendar.py @@ -258,7 +258,7 @@ class TestCalendar(SavepointCaseWithUserDemo): """ Check that mail are sent to the attendees on event creation Check that mail are sent to the added attendees on event edit - Check that mail are NOT sent to the attendees when detaching a recurring event + Check that mail are NOT sent to the attendees when the event date is past """ def _test_one_mail_per_attendee(self, partners): @@ -302,3 +302,16 @@ class TestCalendar(SavepointCaseWithUserDemo): # more email should be sent _test_one_mail_per_attendee(self, partners) + + # create a new event in the past + self.CalendarEvent.create({ + 'name': "NOmailTest", + 'allday': False, + 'recurrency': False, + 'partner_ids': partner_ids, + 'start': fields.Datetime.to_string(now - timedelta(days=10)), + 'stop': fields.Datetime.to_string(now - timedelta(days=9)), + }) + + # no more email should be sent + _test_one_mail_per_attendee(self, partners) |
