[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
This commit is contained in:
Nicolas Martinelli
2017-09-11 13:27:23 +02:00
parent 7d7e94c6ef
commit 7d72a72905
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -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]
@@ -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.