Skip to content

[18.0][IMP] web_company_color: match browser theme color - #3753

Open
LoisRForgeFlow wants to merge 1 commit into
OCA:18.0from
ForgeFlow:18.0-imp-web_company_color-theme-color
Open

LoisRForgeFlow wants to merge 1 commit into
OCA:18.0from
ForgeFlow:18.0-imp-web_company_color-theme-color

Conversation

@LoisRForgeFlow

Copy link
Copy Markdown
Contributor

Odoo hard-codes <meta name="theme-color" content="#71639e"/> in web.webclient_bootstrap. Mobile browsers (Chrome, Brave, Samsung Internet…) paint their address bar with it, so with this module the bar keeps Odoo's default purple while the navbar has the company color.

This PR sets the meta tag to the active company's navbar background color:

  • ir.http.webclient_rendering_context passes the color to the template, and an xpath with position="attributes" sets content. It falls back to #71639e when no navbar color is set.
  • The color is compiled as SCSS, so values like desaturate(#d2e1dd, 30%) give a real CSS color. The result is cached with ormcache, so there is one compile per distinct value.
  • The cookie parsing that picks the active company moves to res.company._get_web_company_color_active_company(). The asset bundle and the theme color now share it. The cookie company must be one of the user's allowed companies, otherwise it falls back to env.company.

Switching company reloads the page, so the bar color follows the company.

Odoo hard-codes the theme-color meta tag to its default navbar color,
so mobile browsers kept painting their address bar with it after the
navbar was recolored. Use the active company's navbar color instead,
compiled as SCSS so expressions like desaturate() also work.

The active company is now taken only from the user's allowed
companies, falling back to the current company.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:web_company_color Module web_company_color series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants