3
0
Fork 0

[IMP] web_switch_context_warning: black, isort, prettier

14.0
hkapatel 2021-07-13 10:26:44 +05:30
parent 5734621181
commit a81dbdbb03
4 changed files with 15 additions and 8 deletions

View File

@ -0,0 +1 @@
../../../../web_switch_context_warning

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@ -1,4 +1,4 @@
odoo.define("web_switch_context_warning.widget", function(require) { odoo.define("web_switch_context_warning.widget", function (require) {
"use strict"; "use strict";
var Widget = require("web.Widget"); var Widget = require("web.Widget");
@ -13,13 +13,13 @@ odoo.define("web_switch_context_warning.widget", function(require) {
} }
var SwitchContextWarningWidget = Widget.extend({ var SwitchContextWarningWidget = Widget.extend({
template: "web_switch_context_warning.warningWidget", template: "web_switch_context_warning.warningWidget",
init: function() { init: function () {
this._super(); this._super();
var self = this; var self = this;
var w = new SharedWorker( var w = new SharedWorker(
"/web_switch_context_warning/static/src/js/switch_context_warning_worker.js" "/web_switch_context_warning/static/src/js/switch_context_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;
} }
@ -32,13 +32,13 @@ odoo.define("web_switch_context_warning.widget", function(require) {
w.port.start(); w.port.start();
w.port.postMessage(this.generateSignature()); w.port.postMessage(this.generateSignature());
}, },
generateSignature: function() { generateSignature: function () {
return [session.uid, session.db].join(); return [session.uid, session.db].join();
}, },
}); });
UserMenu.include({ UserMenu.include({
init: function(parent) { init: function (parent) {
this._super(parent); this._super(parent);
var switchContextWarning = new SwitchContextWarningWidget(); var switchContextWarning = new SwitchContextWarningWidget();
switchContextWarning.insertAfter(".o_main_navbar"); switchContextWarning.insertAfter(".o_main_navbar");

View File

@ -6,17 +6,17 @@ var lastCtx = null;
addEventListener( addEventListener(
"connect", "connect",
function(ee) { function (ee) {
"use strict"; "use strict";
var port = ee.ports[0]; var port = ee.ports[0];
con.push(port); con.push(port);
port.onmessage = function(e) { port.onmessage = function (e) {
var newCtx = e.data; var newCtx = e.data;
if (lastCtx && newCtx !== lastCtx) { if (lastCtx && newCtx !== lastCtx) {
con.forEach(function(eport) { con.forEach(function (eport) {
eport.postMessage({ eport.postMessage({
type: "newCtx", type: "newCtx",
newCtx: newCtx, newCtx: newCtx,