[MIG] web_notify: Migration to 11.0

- Use the 'session' class of the JS Framework (session no lounger bound
to web client)
- Test change: compare emitted & received messages based on content, not
order. Using string comparison raises false positives.
This commit is contained in:
Damien Bouvy
2017-10-29 16:08:20 +01:00
committed by Jairo Llopis
parent 92054cf8a7
commit c1765f97c3
5 changed files with 14 additions and 26 deletions

View File

@@ -3,24 +3,18 @@ odoo.define('web_notify.WebClient', function (require) {
var WebClient = require('web.WebClient');
var base_bus = require('bus.bus');
var session = require('web.session');
WebClient.include({
init: function(parent, client_options){
this._super(parent, client_options);
},
show_application: function() {
var res = this._super();
this.start_polling();
return res
},
on_logout: function() {
var self = this;
base_bus.bus.off('notification', this, this.bus_notification);
this._super();
},
start_polling: function() {
this.channel_warning = 'notify_warning_' + this.session.uid;
this.channel_info = 'notify_info_' + this.session.uid;
this.channel_warning = 'notify_warning_' + session.uid;
this.channel_info = 'notify_info_' + session.uid;
base_bus.bus.add_channel(this.channel_warning);
base_bus.bus.add_channel(this.channel_info);
base_bus.bus.on('notification', this, this.bus_notification);
@@ -33,7 +27,7 @@ WebClient.include({
var message = notification[1];
if (channel === self.channel_warning) {
self.on_message_warning(message);
} else if (channel == self.channel_info) {
} else if (channel === self.channel_info) {
self.on_message_info(message);
}
});