From 402f45b61e3b32c44492713f7e9a768a0a954dda Mon Sep 17 00:00:00 2001 From: hparfr Date: Mon, 11 Jan 2016 15:58:30 +0100 Subject: [PATCH] [IMP] web_switch_company_warning add user and db in change detection --- web_switch_company_warning/README.rst | 10 +++++++--- .../static/src/js/switch_company_warning.js | 8 ++++++-- .../static/src/xml/switch_company_warning.xml | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/web_switch_company_warning/README.rst b/web_switch_company_warning/README.rst index bdf0b58a..3cd13060 100644 --- a/web_switch_company_warning/README.rst +++ b/web_switch_company_warning/README.rst @@ -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 =========== diff --git a/web_switch_company_warning/static/src/js/switch_company_warning.js b/web_switch_company_warning/static/src/js/switch_company_warning.js index a49040fc..f7ba68fb 100644 --- a/web_switch_company_warning/static/src/js/switch_company_warning.js +++ b/web_switch_company_warning/static/src/js/switch_company_warning.js @@ -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(); + } } }); diff --git a/web_switch_company_warning/static/src/xml/switch_company_warning.xml b/web_switch_company_warning/static/src/xml/switch_company_warning.xml index 7943516e..755ef081 100644 --- a/web_switch_company_warning/static/src/xml/switch_company_warning.xml +++ b/web_switch_company_warning/static/src/xml/switch_company_warning.xml @@ -2,7 +2,7 @@