From 6b2cf4664eb8c19baf51a3a6b73eec527acb9ccd Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Sat, 10 Apr 2021 05:39:49 +0200 Subject: [PATCH] [IMP] web_company_color: Support button and link customizing --- web_company_color/models/res_company.py | 64 +++++++++++++++++++++++++ web_company_color/view/res_company.xml | 13 +++-- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/web_company_color/models/res_company.py b/web_company_color/models/res_company.py index 6f07d12ed929..be86ca6dc5fd 100644 --- a/web_company_color/models/res_company.py +++ b/web_company_color/models/res_company.py @@ -44,6 +44,47 @@ class ResCompany(models.Model): } } } + a[href], + a[tabindex], + .btn-link, + .o_external_button { + color: %(color_link_text)s !important; + } + a:hover, + .btn-link:hover { + color: %(color_link_text_hover)s !important; + } + .btn-primary:not(.disabled), + .ui-autocomplete .ui-menu-item.ui-state-focus a { + color: %(color_button_text)s !important; + background-color: %(color_button_bg)s !important; + border-color: %(color_button_bg)s !important; + } + .btn-primary:hover:not(.disabled), + .ui-autocomplete .ui-menu-item.ui-state-focus a:hover { + color: %(color_button_text)s !important; + background-color: %(color_button_bg_hover)s !important; + border-color: %(color_button_bg_hover)s !important; + } + .o_searchview .o_searchview_facet .o_searchview_facet_label { + color: %(color_button_text)s !important; + background-color: %(color_button_bg)s !important; + } + .o_form_view .o_horizontal_separator { + color: %(color_link_text)s !important; + } + .o_form_view .oe_button_box .oe_stat_button .o_button_icon, + .o_form_view .oe_button_box .oe_stat_button .o_stat_info .o_stat_value, + .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 { + color: %(color_link_text)s !important; + } + .o_required_modifier.o_input, .o_required_modifier .o_input { + background-color: lighten(%(color_button_bg)s, 10%%) !important; + } """ company_colors = fields.Serialized() @@ -52,6 +93,16 @@ class ResCompany(models.Model): "Navbar Background Color Hover", sparse="company_colors" ) color_navbar_text = fields.Char("Navbar Text Color", sparse="company_colors") + color_button_text = fields.Char("Button Text Color", sparse="company_colors") + color_button_bg = fields.Char("Button Background Color", sparse="company_colors") + color_button_bg_hover = fields.Char( + "Button Background Color Hover", sparse="company_colors" + ) + color_link_text = fields.Char("Link Text Color", sparse="company_colors") + color_link_text_hover = fields.Char( + "Link Text Color Hover", sparse="company_colors" + ) + scss_modif_timestamp = fields.Char("SCSS Modif. Timestamp") @api.model_create_multi def create(self, vals_list): @@ -73,6 +124,11 @@ def write(self, values): "color_navbar_bg", "color_navbar_bg_hover", "color_navbar_text", + "color_button_bg", + "color_button_bg_hover", + "color_button_text", + "color_link_text", + "color_link_text_hover", ) result = super().write(values) if any([field in values for field in fields_to_check]): @@ -118,6 +174,14 @@ def _scss_get_sanitized_values(self): or "$o-navbar-inverse-link-hover-bg" ), "color_navbar_text": (values.get("color_navbar_text") or "#FFF"), + "color_button_bg": values.get("color_button_bg") or "$primary", + "color_button_bg_hover": values.get("color_button_bg_hover") + or 'darken(theme-color("primary"), 10%)', + "color_button_text": values.get("color_button_text") or "#FFF", + "color_link_text": values.get("color_link_text") + or 'theme-color("primary")', + "color_link_text_hover": values.get("color_link_text_hover") + or 'darken(theme-color("primary"), 10%)', } ) return values diff --git a/web_company_color/view/res_company.xml b/web_company_color/view/res_company.xml index 25265f90c64c..a0f4332553f3 100644 --- a/web_company_color/view/res_company.xml +++ b/web_company_color/view/res_company.xml @@ -15,16 +15,21 @@ name="company_styles" groups="base.group_system" > - - - - +