forked from Techsystech/web
parent
662c091444
commit
fb0744c1f0
|
@ -16,7 +16,7 @@ Known issues / Roadmap
|
||||||
|
|
||||||
* If the browser don't implement Sharded Worker (http://www.w3.org/TR/workers/#sharedworker), the warning message will not be displayed (there is no polyfill).
|
* If the browser don't implement Sharded Worker (http://www.w3.org/TR/workers/#sharedworker), the warning message will not be displayed (there is no polyfill).
|
||||||
|
|
||||||
* Switching company in a separate browser or in private browsing mode will not be detected by this module. It's a limitation of Shared Wworker(limit to browser session, server:port...)
|
* Switching company in a separate browser or in private browsing mode will not be detected by this module. It's a limitation of Shared Worker(limit to browser session, server:port...)
|
||||||
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"name": "Multicompany - Switch Company Warning",
|
"name": "Multicompany - Switch Company Warning",
|
||||||
"summary": "Show a warning if current company has been switched"
|
"summary": "Show a warning if current company has been switched"
|
||||||
" in another tab or window.",
|
" in another tab or window.",
|
||||||
"version": "10.0.0.1.0",
|
"version": "10.0.0.1.1",
|
||||||
"category": "web",
|
"category": "web",
|
||||||
"website": "http://akretion.com",
|
"website": "http://akretion.com",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
|
|
|
@ -24,7 +24,7 @@ msgstr ""
|
||||||
#. openerp-web
|
#. openerp-web
|
||||||
#: code:addons/web_switch_company_warning/static/src/xml/switch_company_warning.xml:5
|
#: code:addons/web_switch_company_warning/static/src/xml/switch_company_warning.xml:5
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "You switched to a different company with another tab or window"
|
msgid "You switched to a different company or database with another tab or window"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: web_switch_company_warning
|
#. module: web_switch_company_warning
|
||||||
|
|
|
@ -16,19 +16,21 @@ odoo.define('web_switch_company_warning.widget', function (require) {
|
||||||
this._super();
|
this._super();
|
||||||
var self = this;
|
var self = this;
|
||||||
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) {
|
if(msg.data.newCtx === self.generateSignature()) {
|
||||||
self.$el.hide();
|
self.$el.hide();
|
||||||
} else {
|
} else {
|
||||||
self.$el.show();
|
self.$el.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
w.port.start();
|
w.port.start();
|
||||||
w.port.postMessage(this.session.company_id);
|
w.port.postMessage(this.generateSignature());
|
||||||
|
},
|
||||||
|
generateSignature: function() {
|
||||||
|
return [this.session.company_id, this.session.db].join();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<template>
|
<template>
|
||||||
<t t-name="web_switch_company_warning.warningWidget">
|
<t t-name="web_switch_company_warning.warningWidget">
|
||||||
<div class="container-fluid bg-warning" style="text-align: center; display:none;">
|
<div class="container-fluid bg-warning" style="text-align: center; display:none;">
|
||||||
<h3>You switched to a different company with another tab or window</h3>
|
<h3>You switched to a different company or database with another tab or window</h3>
|
||||||
<p><button onclick="location.reload(true);" class="btn">Reload</button> to refresh your session</p>
|
<p><button onclick="location.reload(true);" class="btn">Reload</button> to refresh your session</p>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
|
Loading…
Reference in New Issue