From 7d72a72905ce9e13b7be4239aa67eece9140dcb8 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 8 Sep 2017 14:21:18 +0200 Subject: [PATCH] [FIX] calendar, web_calendar: change date - Change the date of an event through the form view => a mail is sent to the attendees. - Change the date of an event thanks to the drag and drop of an event => the mail is not sent. It is necessary to introduce a context key in the write call so we can make the distinction between the write triggered from the drag and drop and the write triggered by a recomputation of fields. Indeed, when the form view is used to change the date, `write` is called several times. We should avoid sending the same email each time. opw-766295 --- addons/calendar/models/calendar.py | 3 ++- addons/web_calendar/static/src/js/web_calendar.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 145614fc045..fa22382b328 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -1406,7 +1406,8 @@ class Meeting(models.Model): partners_to_notify.append(event_attendees_changes['removed_partners'].ids) self.env['calendar.alarm_manager'].notify_next_alarm(partners_to_notify) - if (values.get('start_date') or values.get('start_datetime')) and values.get('active', True): + if (values.get('start_date') or values.get('start_datetime') or + (values.get('start') and self.env.context.get('from_ui'))) and values.get('active', True): for current_meeting in all_meetings: if attendees_create: attendees_create = attendees_create[current_meeting.id] diff --git a/addons/web_calendar/static/src/js/web_calendar.js b/addons/web_calendar/static/src/js/web_calendar.js index be6e1743ddc..51827c27e3c 100644 --- a/addons/web_calendar/static/src/js/web_calendar.js +++ b/addons/web_calendar/static/src/js/web_calendar.js @@ -892,7 +892,7 @@ var CalendarView = View.extend({ var index = this.dataset.get_id_index(id); if (index !== null) { event_id = this.dataset.ids[index]; - this.dataset.write(event_id, data, {}).always(function() { + this.dataset.write(event_id, data, {context: {from_ui: true}}).always(function() { if (is_virtual_id(event_id)) { // this is a virtual ID and so this will create a new event // with an unknown id for us.