fix: Optimize sidebar CSS generation and loading logic

This commit is contained in:
Altahir Hassan 2026-01-07 02:20:59 +04:00
parent 032c6d3f1b
commit 4886662ea2
2 changed files with 7 additions and 10 deletions

View File

@ -40,9 +40,7 @@ class ResConfigSettings(models.TransientModel):
"""Generate CSS rules for sidebar menu state""" """Generate CSS rules for sidebar menu state"""
if self.disable_nav_menu_section: if self.disable_nav_menu_section:
return """ return """
/* Sidebar Menu Disabled - Hide Top Menu Sections */
.o_main_navbar .o_menu_sections { .o_main_navbar .o_menu_sections {
{
display: none!important; display: none!important;
visibility: hidden!important; visibility: hidden!important;
} }

View File

@ -1,14 +1,11 @@
/** @odoo-module **/ /** @odoo-module **/
import { useService } from "@web/core/utils/hooks";
import { registry } from "@web/core/registry"; import { registry } from "@web/core/registry";
import { rpc } from "@web/core/network/rpc"
/** /**
* Load and inject sidebar CSS rules based on configuration * Load and inject sidebar CSS rules based on configuration
*/ */
export function loadSidebarCSS() { export function loadSidebarCSS() {
// Get the RPC service
const rpc = useService("rpc");
const loadCSS = async () => { const loadCSS = async () => {
try { try {
@ -23,10 +20,12 @@ export function loadSidebarCSS() {
} }
); );
console.log('Fetched sidebar CSS:', css);
if (css && css.trim()) { if (css && css.trim()) {
// Create a style element and inject the CSS // Create a style element and inject the CSS
const style = document.createElement('style'); const style = document.createElement('style');
style.type = 'text/css'; // style.type = 'text/css';
style.id = 'sidebar-dynamic-css'; style.id = 'sidebar-dynamic-css';
style.innerHTML = css; style.innerHTML = css;
document.head.appendChild(style); document.head.appendChild(style);
@ -51,4 +50,4 @@ registry.category("web_tour.tours").add("sidebar_css_loader", {
}); });
// Auto-load CSS on page load // Auto-load CSS on page load
// loadSidebarCSS(); loadSidebarCSS();