Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ addon | version | maintainers | summary
[web_action_conditionable](web_action_conditionable/) | 18.0.1.0.0 | | web_action_conditionable
[web_calendar_slot_duration](web_calendar_slot_duration/) | 18.0.1.0.0 | <a href='https://github.com/Yajo'><img src='https://github.com/Yajo.png' width='32' height='32' style='border-radius:50%;' alt='Yajo'/></a> | Customizable calendar slot durations
[web_chatter_position](web_chatter_position/) | 18.0.1.1.1 | <a href='https://github.com/trisdoan'><img src='https://github.com/trisdoan.png' width='32' height='32' style='border-radius:50%;' alt='trisdoan'/></a> | Add an option to change the chatter position
[web_company_color](web_company_color/) | 18.0.1.1.0 | | Web Company Color
[web_company_color](web_company_color/) | 18.0.1.1.1 | | Web Company Color
[web_copy_confirm](web_copy_confirm/) | 18.0.1.0.0 | | Show confirmation dialogue before copying records
[web_dark_mode](web_dark_mode/) | 18.0.1.0.0 | | Enabled Dark Mode for the Odoo Backend
[web_datetime_picker_default_time](web_datetime_picker_default_time/) | 18.0.1.0.0 | <a href='https://github.com/grindtildeath'><img src='https://github.com/grindtildeath.png' width='32' height='32' style='border-radius:50%;' alt='grindtildeath'/></a> | Allows to define a default time on datetime picker
Expand Down
2 changes: 1 addition & 1 deletion web_company_color/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Web Company Color
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3e5f3c3f38a73bd62888ddabe88246540e60d039a5ae554d85784cb1ce1623d3
!! source digest: sha256:34edb79a4d37371edb0fb274655e023771086ac8fbcf3bc29b82ca12eb748c08
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion web_company_color/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Web Company Color",
"category": "web",
"version": "18.0.1.1.0",
"version": "18.0.1.1.1",
"author": "Alexandre Díaz, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"depends": ["web", "base_sparse_field"],
Expand Down
48 changes: 9 additions & 39 deletions web_company_color/models/ir_qweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,20 @@
class QWeb(models.AbstractModel):
_inherit = "ir.qweb"

def _generate_asset_links_cache(
self,
bundle,
css=True,
js=True,
assets_params=None,
rtl=False,
):
res = super()._generate_asset_links_cache(
bundle,
css=css,
js=js,
assets_params=assets_params,
rtl=rtl,
)
if bundle == "web_company_color.company_color_assets":
asset = AssetsBundleCompanyColor(
bundle, [], env=self.env, css=True, js=True
)
res += [asset.get_company_color_asset_node()]
return res
def _get_asset_links(self, bundle, css=True, js=True, debug=None):
"""Inject the active company scss.

def _generate_asset_links(
self,
bundle,
css=True,
js=True,
debug_assets=False,
assets_params=None,
rtl=False,
):
res = super()._generate_asset_links(
bundle,
css=css,
js=js,
debug_assets=debug_assets,
assets_params=assets_params,
rtl=rtl,
)
This must be done outside of the cached methods
(``_generate_asset_links_cache``), because their cache key does not
depend on the company and the cached list is shared by all requests.
"""
res = super()._get_asset_links(bundle, css=css, js=js, debug=debug)
if bundle == "web_company_color.company_color_assets":
asset = AssetsBundleCompanyColor(
bundle, [], env=self.env, css=True, js=True
)
res += [asset.get_company_color_asset_node()]
# Build a new list to not alter the (possibly cached) one
res = res + [asset.get_company_color_asset_node()]
return res

def _get_asset_content(self, bundle, assets_params=None):
Expand Down
60 changes: 24 additions & 36 deletions web_company_color/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,23 @@ def _get_scss_template(self):
background-color: %(color_navbar_bg_hover)s !important;
}
}

> ul {
> li {
> a, > label {
color: %(color_navbar_text)s !important;

&:hover, &:focus, &:active, &:focus:active {
background-color: %(color_navbar_bg_hover)s !important;
}
}
}
}
}
.o_menu_brand {
.o_main_navbar .o_menu_brand {
color: rgba(%(color_navbar_text)s, 0.9) !important;
&:hover, &:focus, &:active, &:focus:active {
background: none !important;
color: %(color_navbar_text)s !important;
&:hover, &:focus, &:active, &:focus:active {
background-color: %(color_navbar_bg_hover)s !important;
}
}

a[href],
a[tabindex],
.btn-link,
.o_external_button {
color: %(color_link_text)s;
.o_main_navbar {
color: none;
}
}
}
a[href],
a[tabindex],
.btn-link,
.o_external_button {
color: %(color_link_text)s;
}
a:hover,
.btn-link:hover {
color: %(color_link_text_hover)s;
.o_main_navbar {
color: none;
}
}
.btn-primary:not(.disabled),
.ui-autocomplete .ui-menu-item > a.ui-state-active {
Expand All @@ -89,12 +71,12 @@ def _get_scss_template(self):
.o_form_view .oe_button_box .oe_stat_button > span .o_stat_value {
color: %(color_link_text)s !important;
}
.o_form_view .o_form_statusbar > .o_statusbar_status >
.o_arrow_button.btn-primary.disabled {
.o_form_view .o_form_statusbar .o_statusbar_status
.o_arrow_button.o_arrow_button_current {
color: %(color_link_text)s !important;
}
.o_required_modifier{
:focus-within {
&:focus-within {
--o-input-border-color: %(color_button_bg)s !important;
--o-caret-color: %(color_button_bg)s !important;
}
Expand Down Expand Up @@ -184,6 +166,8 @@ def write(self, values):

def button_reset_colors(self):
self.write({"company_colors": {}})
# Reload like a regular save does, so the reset colors are applied
return {"type": "ir.actions.client", "tag": "reload_context"}

def button_compute_color(self):
self.ensure_one()
Expand Down Expand Up @@ -215,12 +199,16 @@ def _scss_get_sanitized_values(self):
# This allow extend company_colors and only sanitize selected fields
# or add custom values
values = dict(self.company_colors or {})
# The SCSS is compiled alone, so Odoo SCSS variables
# (like $o-brand-odoo) are not available: use literal colors.
navbar_bg = values.get("color_navbar_bg") or "#71639e"
values.update(
{
"color_navbar_bg": (values.get("color_navbar_bg") or "$o-brand-odoo"),
"color_navbar_bg_hover": (values.get("color_navbar_bg_hover")),
"color_navbar_bg": navbar_bg,
"color_navbar_bg_hover": values.get("color_navbar_bg_hover")
or f"darken({navbar_bg}, 10%)",
"color_navbar_border_bottom": values.get("color_navbar_border_bottom")
or f"darken({values.get('color_navbar_bg') or '$o-brand-odoo'}, 10%)",
or f"darken({navbar_bg}, 10%)",
"color_navbar_text": (values.get("color_navbar_text") or "#FFF"),
"color_button_bg": values.get("color_button_bg") or "#71639e",
"color_button_bg_hover": values.get("color_button_bg_hover")
Expand All @@ -229,7 +217,7 @@ def _scss_get_sanitized_values(self):
"color_link_text": values.get("color_link_text") or "#71639e",
"color_link_text_hover": values.get("color_link_text_hover")
or "darken(#71639e, 10%)",
"color_submenu_text": values.get("color_link_text") or "#374151",
"color_submenu_text": values.get("color_submenu_text") or "#374151",
}
)
return values
Expand Down
4 changes: 2 additions & 2 deletions web_company_color/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Web Company Color</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -372,7 +372,7 @@ <h1>Web Company Color</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3e5f3c3f38a73bd62888ddabe88246540e60d039a5ae554d85784cb1ce1623d3
!! source digest: sha256:34edb79a4d37371edb0fb274655e023771086ac8fbcf3bc29b82ca12eb748c08
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/18.0/web_company_color"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_company_color"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module change navbar colors based in the company logo colors.</p>
Expand Down
2 changes: 1 addition & 1 deletion web_company_color/tests/test_res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_scss_sanitized_values(self):
values = company_id.sudo()._scss_get_sanitized_values()
self.assertEqual(
values["color_navbar_bg"],
"$o-brand-odoo",
"#71639e",
"Invalid Navbar Background Color",
)
company_id.sudo().write({"color_navbar_bg": "#DEAD00"})
Expand Down
1 change: 1 addition & 0 deletions web_company_color/view/res_company.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<field name="color_button_text" widget="color" />
<field name="color_link_text" widget="color" />
<field name="color_link_text_hover" widget="color" />
<field name="color_submenu_text" widget="color" />
</group>
<button
class="btn-primary"
Expand Down
Loading