|
@ -6,9 +6,10 @@ odoo.define('web_switch_company_warning.widget', function (require) { |
|
|
//Show a big banner in the top of the page if the company has been
|
|
|
//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)
|
|
|
//changed in another tab or window (in the same browser)
|
|
|
|
|
|
|
|
|
if (!window.SharedWorker) |
|
|
|
|
|
return; //not supported
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!window.SharedWorker) { |
|
|
|
|
|
//not supported
|
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
var SwitchCompanyWarningWidget = Widget.extend({ |
|
|
var SwitchCompanyWarningWidget = Widget.extend({ |
|
|
template:'WarningWidget', |
|
|
template:'WarningWidget', |
|
|
init: function() { |
|
|
init: function() { |
|
@ -17,12 +18,13 @@ odoo.define('web_switch_company_warning.widget', function (require) { |
|
|
var w = new SharedWorker('/web_switch_company_warning/static/src/js/switch_company_warning_worker.js'); |
|
|
var w = new SharedWorker('/web_switch_company_warning/static/src/js/switch_company_warning_worker.js'); |
|
|
|
|
|
|
|
|
w.port.addEventListener('message', function (msg) { |
|
|
w.port.addEventListener('message', function (msg) { |
|
|
if (msg.data.type !== 'newCtx') |
|
|
|
|
|
|
|
|
if (msg.data.type !== 'newCtx') { |
|
|
return; |
|
|
return; |
|
|
if(msg.data.newCtx != self.session.company_id) { |
|
|
|
|
|
self.$el.show(); |
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if(msg.data.newCtx === self.session.company_id) { |
|
|
self.$el.hide(); |
|
|
self.$el.hide(); |
|
|
|
|
|
} else { |
|
|
|
|
|
self.$el.show(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
w.port.start(); |
|
|
w.port.start(); |
|
|