Skip to content

Instantly share code, notes, and snippets.

@ray-odoo
Last active July 5, 2024 07:44
Show Gist options
  • Save ray-odoo/17a1dc72c7f59314ed1592b1a3db7e0c to your computer and use it in GitHub Desktop.
Save ray-odoo/17a1dc72c7f59314ed1592b1a3db7e0c to your computer and use it in GitHub Desktop.
<!-- Note: the ID's of your Company records may not be 1 and 2, so adjust accordingly -->
<!-- Odoo 15 -->
<data inherit_id="web.layout">
<xpath expr="//body" position="inside">
<t t-if="request.httprequest.cookies.get('cids') and request.httprequest.cookies.get('cids')[0] == '1'">
<style>.o_main_navbar {background-color: #57596F!important;border-bottom: 0px;}</style></t>
<t t-if="request.httprequest.cookies.get('cids') and request.httprequest.cookies.get('cids')[0] == '2'">
<style>.o_main_navbar {background-color: #6B3C3C!important;border-bottom: 0px;}</style></t>
</xpath>
</data>
<!-- Odoo 16 -->
<data inherit_id="web.layout">
<xpath expr="//body" position="inside">
<t t-if="request.httprequest.cookies.get('cids') and request.httprequest.cookies.get('cids')[0] == '1'">
<style>.o_main_navbar {background: linear-gradient(45deg, #57596F, #57596F);
background-color: #57596F!important;border-bottom: 0px;}</style></t>
<t t-if="request.httprequest.cookies.get('cids') and request.httprequest.cookies.get('cids')[0] == '2'">
<style>.o_main_navbar {background: linear-gradient(45deg, #6B3C3C, #6B3C3C);
background-color: #6B3C3C!important;border-bottom: 0px;}</style></t>
</xpath>
</data>
@dynaz
Copy link

dynaz commented Sep 29, 2022

work good thak you

@alh-odoo
Copy link

Confirmed the v16 section still works for v16.3 SaaS

@Captivea-BEL
Copy link

Captivea-BEL commented Jul 13, 2023

This also worked for me in v16 albeit I used a different approach. Adding it below incase it might be of use to someone else. I made mine into a setting on the settings page with a color picker widget. Here is the template I made to pull from the settings.

<template id='my_navbar_web_layout' 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("my_settings.nav_bar_color") if request else False' /> <t t-if='color'> <style>.o_main_navbar {background-color:<t t-esc='color'/>!important;border-bottom: 0px;}</style> </t> </xpath> </data> </template>

Edit... I cant get the code viewer to properly display but hopefully it would make sense if you paste it into an XML formatter

image

@ihzaputra
Copy link

This also worked for me in v16 albeit I used a different approach. Adding it below incase it might be of use to someone else. I made mine into a setting on the settings page with a color picker widget. Here is the template I made to pull from the settings.

<template id='my_navbar_web_layout' 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("my_settings.nav_bar_color") if request else False' /> <t t-if='color'> <style>.o_main_navbar {background-color:<t t-esc='color'/>!important;border-bottom: 0px;}</style> </t> </xpath> </data> </template>

Edit... I cant get the code viewer to properly display but hopefully it would make sense if you paste it into an XML formatter

image

i dont see or have any changes in setting when i try this code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment