|
|
@ -4,16 +4,16 @@ odoo.define('web_switch_company_warning.widget', function (require) { |
|
|
|
var Widget = require('web.Widget'); |
|
|
|
var UserMenu = require('web.UserMenu'); |
|
|
|
var session = require('web.session'); |
|
|
|
//Show a big banner in the top of the page if the company has been
|
|
|
|
//changed in another tab or window (in the same browser)
|
|
|
|
// Show a big banner in the top of the page if the company has been
|
|
|
|
// changed in another tab or window (in the same browser)
|
|
|
|
|
|
|
|
if (!window.SharedWorker) { |
|
|
|
//not supported
|
|
|
|
// Not supported
|
|
|
|
return; |
|
|
|
} |
|
|
|
var SwitchCompanyWarningWidget = Widget.extend({ |
|
|
|
template:'web_switch_company_warning.warningWidget', |
|
|
|
init: function() { |
|
|
|
init: function () { |
|
|
|
this._super(); |
|
|
|
var self = this; |
|
|
|
var w = new SharedWorker('/web_switch_company_warning/static/src/js/switch_company_warning_worker.js'); |
|
|
@ -21,7 +21,7 @@ odoo.define('web_switch_company_warning.widget', function (require) { |
|
|
|
if (msg.data.type !== 'newCtx') { |
|
|
|
return; |
|
|
|
} |
|
|
|
if(msg.data.newCtx === self.generateSignature()) { |
|
|
|
if (msg.data.newCtx === self.generateSignature()) { |
|
|
|
self.$el.hide(); |
|
|
|
} else { |
|
|
|
self.$el.show(); |
|
|
@ -30,17 +30,17 @@ odoo.define('web_switch_company_warning.widget', function (require) { |
|
|
|
w.port.start(); |
|
|
|
w.port.postMessage(this.generateSignature()); |
|
|
|
}, |
|
|
|
generateSignature: function() { |
|
|
|
generateSignature: function () { |
|
|
|
return [session.company_id, session.db].join(); |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
UserMenu.include({ |
|
|
|
init: function(parent) { |
|
|
|
init: function (parent) { |
|
|
|
this._super(parent); |
|
|
|
var switchCompanyWarning = new SwitchCompanyWarningWidget(); |
|
|
|
switchCompanyWarning.insertAfter('.o_main_navbar'); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|