From 2a3b55eecaa8bd24e0f486c56dee92afa8c31bb2 Mon Sep 17 00:00:00 2001 From: hparfr Date: Fri, 26 Apr 2019 19:11:35 +0200 Subject: [PATCH] Add detection of switching database [UPD] Update web_switch_company_warning.pot --- web_switch_company_warning/README.rst | 2 +- web_switch_company_warning/__manifest__.py | 2 +- .../i18n/web_switch_company_warning.pot | 2 +- .../static/src/js/switch_company_warning.js | 8 +++++--- .../static/src/xml/switch_company_warning.xml | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/web_switch_company_warning/README.rst b/web_switch_company_warning/README.rst index bdf0b58a..cdfc5d4b 100644 --- a/web_switch_company_warning/README.rst +++ b/web_switch_company_warning/README.rst @@ -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). - * 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 diff --git a/web_switch_company_warning/__manifest__.py b/web_switch_company_warning/__manifest__.py index 51532b83..0d53e5d8 100644 --- a/web_switch_company_warning/__manifest__.py +++ b/web_switch_company_warning/__manifest__.py @@ -5,7 +5,7 @@ "name": "Multicompany - Switch Company Warning", "summary": "Show a warning if current company has been switched" " in another tab or window.", - "version": "10.0.0.1.0", + "version": "10.0.0.1.1", "category": "web", "website": "http://akretion.com", "license": "AGPL-3", diff --git a/web_switch_company_warning/i18n/web_switch_company_warning.pot b/web_switch_company_warning/i18n/web_switch_company_warning.pot index 10fc1db6..ccf2d1b5 100644 --- a/web_switch_company_warning/i18n/web_switch_company_warning.pot +++ b/web_switch_company_warning/i18n/web_switch_company_warning.pot @@ -24,7 +24,7 @@ msgstr "" #. openerp-web #: code:addons/web_switch_company_warning/static/src/xml/switch_company_warning.xml:5 #, 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 "" #. module: web_switch_company_warning 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 d0053164..aa017e3e 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 @@ -16,19 +16,21 @@ odoo.define('web_switch_company_warning.widget', function (require) { this._super(); var self = this; var w = new SharedWorker('/web_switch_company_warning/static/src/js/switch_company_warning_worker.js'); - w.port.addEventListener('message', function (msg) { if (msg.data.type !== 'newCtx') { return; } - if(msg.data.newCtx === self.session.company_id) { + if(msg.data.newCtx === self.generateSignature()) { self.$el.hide(); } else { self.$el.show(); } }); 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(); } }); 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 13612008..3bf86e9d 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 @@