Apply TNCSC favicon through frontend and backend assets
Some checks failed
CI / Brand-leak check (push) Has been cancelled
CI / flake8 / pylint-odoo / manifest completeness (push) Has been cancelled
CI / Install all modules with --test-enable (push) Has been cancelled

Replace rendered favicon and Apple touch icon links with the official PNG using a versioned URL, including layouts whose database template overrides have not taken effect. Create an icon link when absent without duplicates.

Validated injected script on live homepage and login HTML, PNG response, repeated execution, JavaScript syntax, and manifest completeness. Production still requires loading the updated assets.
This commit is contained in:
metatroncubeswdev 2026-09-27 10:07:39 -04:00
parent 191b12b0cd
commit df80bc9560
2 changed files with 29 additions and 0 deletions

View File

@ -57,10 +57,12 @@ that applies to the community_* product modules.
'tncsc_deployment/static/src/scss/primary_variables.scss',
],
'web.assets_frontend': [
'tncsc_deployment/static/src/js/favicon.js',
'tncsc_deployment/static/src/scss/login_theme.scss',
'tncsc_deployment/static/src/scss/website_navigation.scss',
],
'web.assets_backend': [
'tncsc_deployment/static/src/js/favicon.js',
'tncsc_deployment/static/src/scss/tncsc_backend_theme.scss',
'tncsc_deployment/static/src/scss/event_kanban.scss',
'tncsc_deployment/static/src/scss/community_dashboard.scss',

View File

@ -0,0 +1,27 @@
/** @odoo-module **/
// Apply branding to rendered layouts too, including website-specific copies.
// A versioned URL avoids reusing a previously cached database favicon.
function setTncscFavicon() {
const href = "/tncsc_deployment/static/src/img/brand/logo.png?v=tncsc-1";
const icons = [...document.head.querySelectorAll(
'link[rel~="icon"], link[rel="apple-touch-icon"], link[rel="apple-touch-icon-precomposed"]'
)];
if (!icons.some((icon) => icon.rel.split(/\s+/).includes("icon"))) {
const icon = document.createElement("link");
icon.rel = "icon";
document.head.appendChild(icon);
icons.push(icon);
}
for (const icon of icons) {
icon.type = "image/png";
icon.href = href;
icon.removeAttribute("sizes");
}
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", setTncscFavicon, { once: true });
} else {
setTncscFavicon();
}