Last active
November 27, 2025 14:22
-
-
Save ray-odoo/17a1dc72c7f59314ed1592b1a3db7e0c to your computer and use it in GitHub Desktop.
Author
While doing a v18 upgrade this is what I am settling with for v18
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id='navbar_web_layout_comp_color' inherit_id='web.layout'>
<data inherit_id="web.layout">
<xpath expr="//body" position="inside">
<t t-set="color" t-value='request.env["ir.config_parameter"].sudo().get_param("custom_icp.nav_bar_color") if request else False' />
<t t-if='color'>
<t t-set="text_color">
<t t-set="r" t-value="int(color[1:3], 16)"/>
<t t-set="g" t-value="int(color[3:5], 16)"/>
<t t-set="b" t-value="int(color[5:7], 16)"/>
<t t-set="brightness" t-value="(r * 299 + g * 587 + b * 114) / 1000"/>
<t t-set="text_color_val" t-value="'white' if brightness < 128 else 'black'"/>
</t>
<style>
.o_main_navbar {
background-color: <t t-esc="color"/> !important;
background: linear-gradient(45deg, <t t-esc="color"/>, <t t-esc="color"/>);
color: <t t-esc="text_color_val"/> !important;
}
.o_main_navbar *,
.o_main_navbar .breadcrumb-item,
.o_main_navbar .o_menu_toggle,
.o_main_navbar .o_user_menu,
.o_main_navbar a,
.o_main_navbar .o_MessagingMenu,
.o_main_navbar .o_debug_manager,
.o_main_navbar .o_menu_sections,
.o_main_navbar .o_menu_brand,
.o_main_navbar .o_switch_company_menu,
.o_main_navbar .dropdown-toggle {
color: <t t-esc="text_color_val"/> !important;
}
.o_main_navbar button,
.o_main_navbar .o_nav_entry,
.o_main_navbar .btn,
.o_main_navbar .btn-secondary,
.o_main_navbar .badge,
.o_main_navbar .dropdown-menu .dropdown-item {
color: <t t-esc="text_color_val"/> !important;
background-color: transparent !important;
border-color: rgba(255, 255, 255, 0.3);
}
</style>
</t>
</xpath>
</data>
</template>
</odoo>
Edit: Cant get screenshot to upload :(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment



Anyone have any ideas on how to get the rest of the theme to use a different colour?