[IMP] web_switch_company_warning

add user and db in change detection
pull/289/head
hparfr 2016-01-11 15:58:30 +01:00
parent fc6a5ece31
commit 402f45b61e
3 changed files with 14 additions and 6 deletions

View File

@ -7,17 +7,21 @@ Web Switch Company Warning
===========================
Shows a warning if current company has been switched in another tab or window.
Shows a warning if current (company|user|db) has been changed within another tab or window.
Known issues / Roadmap
======================
Known issues
============
* 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...)
Updates
=======
* Jan 2016 : [IMP] add user and db in change detection
* Sep 2015 : First version
Bug Tracker
===========

View File

@ -25,7 +25,7 @@ openerp.web_switch_company_warning = function (instance) {
if (msg.data.type !== 'newCtx')
return;
if(msg.data.newCtx != self.session.company_id) {
if(msg.data.newCtx != signature(self.session)) {
self.$el.show();
} else {
self.$el.hide();
@ -33,7 +33,11 @@ openerp.web_switch_company_warning = function (instance) {
});
w.port.start();
w.port.postMessage(this.session.company_id);
w.port.postMessage(signature(this.session));
function signature(session) {
return [session.db, session.uid, session.company_id].join();
}
}
});

View File

@ -2,7 +2,7 @@
<template>
<t t-name="web_switch_company_warning.warningWidget">
<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 user with another tab or window</h3>
<p><button onclick="location.reload(true);" class="btn">Reload</button> to refresh your session</p>
</div>
</t>