summaryrefslogtreecommitdiff
path: root/addons/calendar/static/src
diff options
context:
space:
mode:
authorJorge Pinna Puissant <jpp@odoo.com>2019-11-06 10:08:42 +0000
committerfw-bot <otis@odoo.com>2019-11-06 16:59:17 +0000
commitc79311d00e17bbfd00a2873afec153d0b57d5d36 (patch)
treeeb0a1d6e3e8accb6f0283097ca47c5cc80b9b91f /addons/calendar/static/src
parentdaa693fe930a39c1c134d91e0aa9e89624fd28d4 (diff)
[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#39909 X-original-commit: 8ab0bfeaa7b6c3e1642064d123197b1cba74355d Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Lucas Perais <lpe@odoo.com>
Diffstat (limited to 'addons/calendar/static/src')
-rw-r--r--addons/calendar/static/src/js/base_calendar.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/addons/calendar/static/src/js/base_calendar.js b/addons/calendar/static/src/js/base_calendar.js
index 0a9dd625662..600ebd4b01a 100644
--- a/addons/calendar/static/src/js/base_calendar.js
+++ b/addons/calendar/static/src/js/base_calendar.js
@@ -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);
});