summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
l---------inject/1/apple-touch-icon.png1
l---------inject/1/favicon.ico1
l---------inject/1/overrides.css1
l---------inject/1/overrides.js1
l---------inject/10/apple-touch-icon.png1
l---------inject/10/favicon.ico1
l---------inject/10/overrides.css1
l---------inject/10/overrides.js1
l---------inject/2/apple-touch-icon.png1
l---------inject/2/favicon.ico1
l---------inject/2/overrides.css1
l---------inject/2/overrides.js1
l---------inject/3/apple-touch-icon.png1
l---------inject/3/favicon.ico1
l---------inject/3/overrides.css1
l---------inject/3/overrides.js1
l---------inject/4/apple-touch-icon.png1
l---------inject/4/favicon.ico1
l---------inject/4/overrides.css1
l---------inject/4/overrides.js1
l---------inject/5/apple-touch-icon.png1
l---------inject/5/favicon.ico1
l---------inject/5/overrides.css1
l---------inject/5/overrides.js1
l---------inject/6/apple-touch-icon.png1
l---------inject/6/favicon.ico1
l---------inject/6/overrides.css1
l---------inject/6/overrides.js1
l---------inject/7/apple-touch-icon.png1
l---------inject/7/favicon.ico1
l---------inject/7/overrides.css1
l---------inject/7/overrides.js1
l---------inject/8/apple-touch-icon.png1
l---------inject/8/favicon.ico1
l---------inject/8/overrides.css1
l---------inject/8/overrides.js1
l---------inject/9/apple-touch-icon.png1
l---------inject/9/favicon.ico1
l---------inject/9/overrides.css1
l---------inject/9/overrides.js1
-rw-r--r--inject/apple-touch-icon.pngbin0 -> 27552 bytes
-rw-r--r--inject/company-switcher.css10
-rw-r--r--inject/company-switcher.js90
-rw-r--r--inject/favicon.icobin0 -> 1150 bytes
-rw-r--r--inject/overrides.css1
-rw-r--r--inject/overrides.js3
46 files changed, 144 insertions, 0 deletions
diff --git a/inject/1/apple-touch-icon.png b/inject/1/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/1/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/1/favicon.ico b/inject/1/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/1/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/1/overrides.css b/inject/1/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/1/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/1/overrides.js b/inject/1/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/1/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/10/apple-touch-icon.png b/inject/10/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/10/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/10/favicon.ico b/inject/10/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/10/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/10/overrides.css b/inject/10/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/10/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/10/overrides.js b/inject/10/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/10/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/2/apple-touch-icon.png b/inject/2/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/2/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/2/favicon.ico b/inject/2/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/2/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/2/overrides.css b/inject/2/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/2/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/2/overrides.js b/inject/2/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/2/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/3/apple-touch-icon.png b/inject/3/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/3/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/3/favicon.ico b/inject/3/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/3/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/3/overrides.css b/inject/3/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/3/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/3/overrides.js b/inject/3/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/3/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/4/apple-touch-icon.png b/inject/4/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/4/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/4/favicon.ico b/inject/4/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/4/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/4/overrides.css b/inject/4/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/4/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/4/overrides.js b/inject/4/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/4/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/5/apple-touch-icon.png b/inject/5/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/5/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/5/favicon.ico b/inject/5/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/5/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/5/overrides.css b/inject/5/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/5/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/5/overrides.js b/inject/5/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/5/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/6/apple-touch-icon.png b/inject/6/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/6/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/6/favicon.ico b/inject/6/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/6/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/6/overrides.css b/inject/6/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/6/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/6/overrides.js b/inject/6/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/6/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/7/apple-touch-icon.png b/inject/7/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/7/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/7/favicon.ico b/inject/7/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/7/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/7/overrides.css b/inject/7/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/7/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/7/overrides.js b/inject/7/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/7/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/8/apple-touch-icon.png b/inject/8/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/8/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/8/favicon.ico b/inject/8/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/8/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/8/overrides.css b/inject/8/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/8/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/8/overrides.js b/inject/8/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/8/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/9/apple-touch-icon.png b/inject/9/apple-touch-icon.png
new file mode 120000
index 0000000..2eb3b7a
--- /dev/null
+++ b/inject/9/apple-touch-icon.png
@@ -0,0 +1 @@
+../apple-touch-icon.png \ No newline at end of file
diff --git a/inject/9/favicon.ico b/inject/9/favicon.ico
new file mode 120000
index 0000000..cf3a36c
--- /dev/null
+++ b/inject/9/favicon.ico
@@ -0,0 +1 @@
+../favicon.ico \ No newline at end of file
diff --git a/inject/9/overrides.css b/inject/9/overrides.css
new file mode 120000
index 0000000..71d9e04
--- /dev/null
+++ b/inject/9/overrides.css
@@ -0,0 +1 @@
+../overrides.css \ No newline at end of file
diff --git a/inject/9/overrides.js b/inject/9/overrides.js
new file mode 120000
index 0000000..e6ea473
--- /dev/null
+++ b/inject/9/overrides.js
@@ -0,0 +1 @@
+../overrides.js \ No newline at end of file
diff --git a/inject/apple-touch-icon.png b/inject/apple-touch-icon.png
new file mode 100644
index 0000000..e16cb2c
--- /dev/null
+++ b/inject/apple-touch-icon.png
Binary files differ
diff --git a/inject/company-switcher.css b/inject/company-switcher.css
new file mode 100644
index 0000000..1d598d8
--- /dev/null
+++ b/inject/company-switcher.css
@@ -0,0 +1,10 @@
+.o_switch_company_item div:nth-child(1) {
+ display: none;
+}
+
+/* Disable the company switcher by preventing pointer events:
+ .o_switch_company_menu button:nth-child(1) {
+ pointer-events: none;
+ opacity: 0.5;
+}
+*/
diff --git a/inject/company-switcher.js b/inject/company-switcher.js
new file mode 100644
index 0000000..b491b8a
--- /dev/null
+++ b/inject/company-switcher.js
@@ -0,0 +1,90 @@
+export function registerObserver() {
+ document.addEventListener("DOMContentLoaded", function () {
+
+ // When the DOM loaded, only the Web client framework is available, Odoo loads its
+ // stuff later and so we must wait, and react to new nodes as they are added
+ const root = document.querySelector(".o_web_client");
+
+ if (!root) {
+ return;
+ }
+
+ // This function is called (see below) whenever a DOM mutation happens
+ const callback = function (mutationsList, observer) {
+ for (let mutation of mutationsList) {
+ try {
+ if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
+ // We are only interested in children that are adding nodes
+ const elem = mutation.addedNodes.item(0);
+
+ if (elem.classList === undefined) {
+ // This skips nodes that are not HTML tags
+ continue;
+ }
+ else if (elem.attributes.toni) {
+ // As we clone tags further down, and add those clones, we'd enter an
+ // infinite recursion unless we skip elements we created, which are
+ // marked with an attribute
+ console.debug("Skipping TONI element:", elem);
+ continue;
+ }
+
+ if (elem.classList.contains("o_switch_company_item")) {
+ // Now we have an individual company menu item in `elem`. To get rid of the
+ // Odoo-provided click-event handler, we clone it, and replace the original,
+ // as cloning does not copy the event handlers
+ try {
+ let clone = elem.cloneNode(true);
+ clone.attributes.toni = true
+ clone.addEventListener('click', () => {
+ // … and we add our own event handler that opens a new window on the
+ // subdomain URL for the other company
+ const cid = clone.attributes["data-company-id"].value;
+ const url = document.URL.replace(/:\/\/(\d+\.)?odoo/, `://${cid}.odoo`);
+ if (url) {
+
+ console.debug("Opening new window on", url);
+ const newwin = window.open(url, "_blank", "noreferrer");
+ if (newwin) {
+ newwin.focus();
+ }
+
+ const menubtn = document.querySelector(".o_switch_company_menu > button:nth-child(1)");
+ if (menubtn) {
+ // Finally, click the menu, so that it disappears
+ menubtn.click();
+ }
+
+ } else {
+ console.error("URL is empty, clone is:", clone);
+ }
+ });
+ elem.parentNode.replaceChild(clone, elem);
+ console.debug("Replaced with TONI clone:", clone);
+ } catch (e) { console.error("While cloning element:", elem, e); }
+ // TODO: The following is an attempt to modify the document title and include the
+ // company name. but it get overwritten by Odoo right away, so we need another
+ // approach
+ /*
+ } else if (elem.classList.contains("o_switch_company_menu")) {
+ const btn = elem.childNodes[0];
+ const company = btn?.title;
+ if (company !== undefined) {
+ const titleelem = document.querySelector("title");
+ titleelem.innerText += ` | ${company}`;
+ }
+ */
+ }
+ }
+ }
+ catch (e) { console.error("While handling mutation:", mutation, e); };
+ }
+ };
+
+ // Configure and start the MutationObserver
+ const observer = new MutationObserver(callback);
+ const config = { childList: true, subtree: true };
+ observer.observe(root, config);
+ console.info("Installed TONI observer");
+ });
+}
diff --git a/inject/favicon.ico b/inject/favicon.ico
new file mode 100644
index 0000000..961390f
--- /dev/null
+++ b/inject/favicon.ico
Binary files differ
diff --git a/inject/overrides.css b/inject/overrides.css
new file mode 100644
index 0000000..a1c2048
--- /dev/null
+++ b/inject/overrides.css
@@ -0,0 +1 @@
+@import url("/inject/company-switcher.css");
diff --git a/inject/overrides.js b/inject/overrides.js
new file mode 100644
index 0000000..fcaf665
--- /dev/null
+++ b/inject/overrides.js
@@ -0,0 +1,3 @@
+import { registerObserver } from '/inject/company-switcher.js';
+
+registerObserver();