From a81dbdbb03113c09fe49f935a6217d631936c9d8 Mon Sep 17 00:00:00 2001 From: hkapatel Date: Tue, 13 Jul 2021 10:26:44 +0530 Subject: [PATCH] [IMP] web_switch_context_warning: black, isort, prettier --- .../odoo/addons/web_switch_context_warning | 1 + setup/web_switch_context_warning/setup.py | 6 ++++++ .../static/src/js/switch_context_warning.js | 10 +++++----- .../static/src/js/switch_context_warning_worker.js | 6 +++--- 4 files changed, 15 insertions(+), 8 deletions(-) create mode 120000 setup/web_switch_context_warning/odoo/addons/web_switch_context_warning create mode 100644 setup/web_switch_context_warning/setup.py diff --git a/setup/web_switch_context_warning/odoo/addons/web_switch_context_warning b/setup/web_switch_context_warning/odoo/addons/web_switch_context_warning new file mode 120000 index 000000000..f253d8443 --- /dev/null +++ b/setup/web_switch_context_warning/odoo/addons/web_switch_context_warning @@ -0,0 +1 @@ +../../../../web_switch_context_warning \ No newline at end of file diff --git a/setup/web_switch_context_warning/setup.py b/setup/web_switch_context_warning/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_switch_context_warning/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_switch_context_warning/static/src/js/switch_context_warning.js b/web_switch_context_warning/static/src/js/switch_context_warning.js index 3615013e3..80533b070 100644 --- a/web_switch_context_warning/static/src/js/switch_context_warning.js +++ b/web_switch_context_warning/static/src/js/switch_context_warning.js @@ -1,4 +1,4 @@ -odoo.define("web_switch_context_warning.widget", function(require) { +odoo.define("web_switch_context_warning.widget", function (require) { "use strict"; var Widget = require("web.Widget"); @@ -13,13 +13,13 @@ odoo.define("web_switch_context_warning.widget", function(require) { } var SwitchContextWarningWidget = Widget.extend({ template: "web_switch_context_warning.warningWidget", - init: function() { + init: function () { this._super(); var self = this; var w = new SharedWorker( "/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") { return; } @@ -32,13 +32,13 @@ odoo.define("web_switch_context_warning.widget", function(require) { w.port.start(); w.port.postMessage(this.generateSignature()); }, - generateSignature: function() { + generateSignature: function () { return [session.uid, session.db].join(); }, }); UserMenu.include({ - init: function(parent) { + init: function (parent) { this._super(parent); var switchContextWarning = new SwitchContextWarningWidget(); switchContextWarning.insertAfter(".o_main_navbar"); diff --git a/web_switch_context_warning/static/src/js/switch_context_warning_worker.js b/web_switch_context_warning/static/src/js/switch_context_warning_worker.js index c1bf96400..7c9d1446f 100644 --- a/web_switch_context_warning/static/src/js/switch_context_warning_worker.js +++ b/web_switch_context_warning/static/src/js/switch_context_warning_worker.js @@ -6,17 +6,17 @@ var lastCtx = null; addEventListener( "connect", - function(ee) { + function (ee) { "use strict"; var port = ee.ports[0]; con.push(port); - port.onmessage = function(e) { + port.onmessage = function (e) { var newCtx = e.data; if (lastCtx && newCtx !== lastCtx) { - con.forEach(function(eport) { + con.forEach(function (eport) { eport.postMessage({ type: "newCtx", newCtx: newCtx,