[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#60414

X-original-commit: 3b1df8f57e0cd342fe7f9ff7bd34100b2c821569
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: Achraf <abz-odoo@users.noreply.github.com>
This commit is contained in:
Achraf (abz)
2020-10-21 09:12:44 +00:00
parent bd26e75f34
commit 4f28864617
2 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -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
+14 -1
View File
@@ -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)