Browse Source

Merge pull request #289 from akretion/web_switch_company_warning-imp-detection

Web switch company warning imp detection
pull/307/head
Sylvain LE GAL 9 years ago
parent
commit
00c4de4271
  1. 10
      web_switch_company_warning/README.rst
  2. 16
      web_switch_company_warning/i18n/en.po
  3. 10
      web_switch_company_warning/i18n/fr.po
  4. 6
      web_switch_company_warning/i18n/web_switch_company_warning.pot
  5. 7
      web_switch_company_warning/static/src/js/switch_company_warning.js
  6. 2
      web_switch_company_warning/static/src/xml/switch_company_warning.xml

10
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). * 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 Wworker(limit to browser session, server:port...)
Updates
=======
* Jan 2016 : [IMP] add user and db in change detection
* Sep 2015 : First version
Bug Tracker Bug Tracker
=========== ===========

16
web_switch_company_warning/i18n/en.po

@ -7,15 +7,17 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: web (8.0)\n" "Project-Id-Version: web (8.0)\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-23 13:46+0000\n"
"PO-Revision-Date: 2015-11-07 11:21+0000\n"
"POT-Creation-Date: 2016-01-11 16:22+0100\n"
"PO-Revision-Date: 2016-01-11 16:22+0100\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n" "Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: English (http://www.transifex.com/oca/OCA-web-8-0/language/en/)\n"
"Language-Team: English (http://www.transifex.com/oca/OCA-web-8-0/language/"
"en/)\n"
"Language: en\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: en\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.6\n"
#. module: web_switch_company_warning #. module: web_switch_company_warning
#. openerp-web #. openerp-web
@ -28,8 +30,8 @@ msgstr "Reload"
#. 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"
msgstr "You switched to a different company with another tab or window"
msgid "You switched to a different company or user with another tab or window"
msgstr "You switched to a different company or user with another tab or window"
#. module: web_switch_company_warning #. module: web_switch_company_warning
#. openerp-web #. openerp-web

10
web_switch_company_warning/i18n/fr.po

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 8.0\n" "Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-20 22:08+0000\n"
"PO-Revision-Date: 2015-10-21 00:15+0100\n"
"POT-Creation-Date: 2016-01-11 16:19+0100\n"
"PO-Revision-Date: 2016-01-11 16:20+0100\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"Language: fr\n" "Language: fr\n"
@ -15,7 +15,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n" "Plural-Forms: \n"
"X-Generator: Poedit 1.7.5\n"
"X-Generator: Poedit 1.8.6\n"
#. module: web_switch_company_warning #. module: web_switch_company_warning
#. openerp-web #. openerp-web
@ -28,8 +28,8 @@ msgstr "Recharger"
#. 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"
msgstr "Vous avez basculé vers une société différente depuis un autre onglet ou fenêtre."
msgid "You switched to a different company or user with another tab or window"
msgstr "Vous avez basculé vers une société ou un utilisateur différent depuis un autre onglet ou fenêtre."
#. module: web_switch_company_warning #. module: web_switch_company_warning
#. openerp-web #. openerp-web

6
web_switch_company_warning/i18n/web_switch_company_warning.pot

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 8.0\n" "Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-20 22:08+0000\n"
"PO-Revision-Date: 2015-10-20 22:08+0000\n"
"POT-Creation-Date: 2016-01-11 15:15+0000\n"
"PO-Revision-Date: 2016-01-11 15:15+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -26,7 +26,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 user with another tab or window"
msgstr "" msgstr ""
#. module: web_switch_company_warning #. module: web_switch_company_warning

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

2
web_switch_company_warning/static/src/xml/switch_company_warning.xml

@ -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 user 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…
Cancel
Save