Skip to content
Snippets Groups Projects
Commit 9fd457b5 authored by Jorge Pinna Puissant's avatar Jorge Pinna Puissant Committed by fw-bot
Browse files

[FIX] calendar: multiple notifications for an event


Before this commit, when an event have multiples notifications, if the
first notification is not ack when the second notification is shown, not
only two are visualized but multiples notifications are raised.

Now, only the correct number of notifications are shown.

opw-2070852

closes odoo/odoo#39901

X-original-commit: 8ab0bfeaa7b6c3e1642064d123197b1cba74355d
Signed-off-by: default avatarAaron Bohy (aab) <aab@odoo.com>
Co-authored-by: default avatarAaron Bohy <aab@odoo.com>
Co-authored-by: default avatarLucas Perais <lpe@odoo.com>
parent ae7982b3
No related branches found
No related tags found
No related merge requests found
......@@ -454,6 +454,7 @@ class AlarmManager(models.AbstractModel):
delta = delta.seconds + delta.days * 3600 * 24
return {
'alarm_id': alarm.id,
'event_id': meeting.id,
'title': meeting.name,
'message': message,
......
......@@ -38,12 +38,12 @@ var CalendarNotification = Notification.extend({
},
'click .link2recall': function() {
this.destroy(true);
this.close();
},
'click .link2showed': function() {
this._rpc({route: '/calendar/notify_ack'})
.then(this.destroy.bind(this), this.destroy.bind(this));
.then(this.close.bind(this, false), this.close.bind(this, false));
},
});
},
......@@ -57,22 +57,25 @@ WebClient.include({
// Clear previously set timeouts and destroy currently displayed calendar notifications
clearTimeout(this.get_next_calendar_notif_timeout);
_.each(this.calendar_notif_timeouts, clearTimeout);
_.each(this.calendar_notif, function (notificationID) {
self.call('notification', 'close', notificationID, true);
});
this.calendar_notif_timeouts = {};
this.calendar_notif = {};
// For each notification, set a timeout to display it
_.each(notifications, function(notif) {
self.calendar_notif_timeouts[notif.event_id] = setTimeout(function() {
var key = notif.event_id + ',' + notif.alarm_id;
if (key in self.calendar_notif) {
return;
}
self.calendar_notif_timeouts[key] = setTimeout(function () {
var notificationID = self.call('notification', 'notify', {
Notification: CalendarNotification,
title: notif.title,
message: notif.message,
eventID: notif.event_id,
onClose: function () {
delete self.calendar_notif[key];
},
});
self.calendar_notif[notif.event_id] = notificationID;
self.calendar_notif[key] = notificationID;
}, notif.timer * 1000);
last_notif_timer = Math.max(last_notif_timer, notif.timer);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment