[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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user