diff --git a/web_company_color/README.rst b/web_company_color/README.rst index 07664e800..6a83cc7aa 100644 --- a/web_company_color/README.rst +++ b/web_company_color/README.rst @@ -7,7 +7,7 @@ Web Company Color !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:8a814ac88491029ca65ef378be730bd05a762604c5913f24f9cf1c6ea5b160cb + !! source digest: sha256:d3127248cefbf2ea4da8c6e1569a1a9129edd5e5d7eb612c8d805bacb56a5ab0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -70,17 +70,17 @@ Authors Contributors ------------ -- Jordi Ballester Alomar (ForgeFlow) -- Lois Rilo (ForgeFlow) -- Simone Orsi -- Iván Antón -- Bernat Puig (ForgeFlow) -- Dhara Solanki -- `Tecnativa `__: +- Jordi Ballester Alomar (ForgeFlow) +- Lois Rilo (ForgeFlow) +- Simone Orsi +- Iván Antón +- Bernat Puig (ForgeFlow) +- Dhara Solanki +- `Tecnativa `__: - - Jairo Llopis - - Alexandre Díaz - - Carlos Roca + - Jairo Llopis + - Alexandre Díaz + - Carlos Roca Maintainers ----------- diff --git a/web_company_color/__manifest__.py b/web_company_color/__manifest__.py index 9b50bee47..5baf1058e 100644 --- a/web_company_color/__manifest__.py +++ b/web_company_color/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Web Company Color", "category": "web", - "version": "16.0.1.2.3", + "version": "17.0.1.0.0", "author": "Alexandre Díaz, Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", "depends": ["web", "base_sparse_field"], diff --git a/web_company_color/hooks.py b/web_company_color/hooks.py index ca23677bf..04ac7f0b7 100644 --- a/web_company_color/hooks.py +++ b/web_company_color/hooks.py @@ -1,15 +1,12 @@ # Copyright 2019 Alexandre Díaz # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import SUPERUSER_ID, api from .models.res_company import URL_BASE -def uninstall_hook(cr, registry): - env = api.Environment(cr, SUPERUSER_ID, {}) +def uninstall_hook(env): env["ir.attachment"].search([("url", "=like", "%s%%" % URL_BASE)]).unlink() -def post_init_hook(cr, registry): - env = api.Environment(cr, SUPERUSER_ID, {}) +def post_init_hook(env): env["res.company"].search([]).scss_create_or_update_attachment() diff --git a/web_company_color/i18n/fr.po b/web_company_color/i18n/fr.po index 2cc3062ce..8a2aa79d1 100644 --- a/web_company_color/i18n/fr.po +++ b/web_company_color/i18n/fr.po @@ -20,7 +20,8 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:web_company_color.view_company_form msgid "" "\n" -" In order for the changes to take effect, please refresh\n" +" In order for the changes to take effect, please " +"refresh\n" " the page." msgstr "" "\n" diff --git a/web_company_color/i18n/hr.po b/web_company_color/i18n/hr.po index a0f2a8177..3745d8d76 100644 --- a/web_company_color/i18n/hr.po +++ b/web_company_color/i18n/hr.po @@ -13,8 +13,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "X-Generator: Weblate 3.8\n" #. module: web_company_color diff --git a/web_company_color/i18n/pt.po b/web_company_color/i18n/pt.po index 29faae2c0..d51eb1ef1 100644 --- a/web_company_color/i18n/pt.po +++ b/web_company_color/i18n/pt.po @@ -20,7 +20,8 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:web_company_color.view_company_form msgid "" "\n" -" In order for the changes to take effect, please refresh\n" +" In order for the changes to take effect, please " +"refresh\n" " the page." msgstr "" "\n" diff --git a/web_company_color/i18n/web_company_color.pot b/web_company_color/i18n/web_company_color.pot index 1cd32a3ee..60216b0d0 100644 --- a/web_company_color/i18n/web_company_color.pot +++ b/web_company_color/i18n/web_company_color.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" +"Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" diff --git a/web_company_color/migrations/16.0.1.2.1/post-migration.py b/web_company_color/migrations/16.0.1.2.1/post-migration.py deleted file mode 100644 index 73b0a471b..000000000 --- a/web_company_color/migrations/16.0.1.2.1/post-migration.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2024 Tecnativa - Carlos Roca -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openupgradelib import openupgrade - - -@openupgrade.migrate() -def migrate(env, version): - companies = env["res.company"].search([("company_colors", "!=", False)]) - companies.scss_create_or_update_attachment() diff --git a/web_company_color/models/assetsbundle.py b/web_company_color/models/assetsbundle.py index aec30736c..c26e0e16f 100644 --- a/web_company_color/models/assetsbundle.py +++ b/web_company_color/models/assetsbundle.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.http import request -from odoo.addons.base.models.assetsbundle import AssetsBundle, ScssStylesheetAsset +from odoo.addons.base.models.assetsbundle import AssetsBundle class AssetsBundleCompanyColor(AssetsBundle): @@ -17,6 +17,4 @@ class AssetsBundleCompanyColor(AssetsBundle): company_id = ( self.env["res.company"].browse(active_company_id) or self.env.company ) - asset = ScssStylesheetAsset(self, url=company_id.scss_get_url()) - compiled = self.compile_css(asset.compile, asset.get_source()) - return "style", {}, compiled + return company_id.scss_get_url() diff --git a/web_company_color/models/ir_qweb.py b/web_company_color/models/ir_qweb.py index 944288c50..4ec18387e 100644 --- a/web_company_color/models/ir_qweb.py +++ b/web_company_color/models/ir_qweb.py @@ -8,19 +8,20 @@ from .assetsbundle import AssetsBundleCompanyColor class QWeb(models.AbstractModel): _inherit = "ir.qweb" - def _generate_asset_nodes_cache( + def _generate_asset_links_cache( self, bundle, css=True, js=True, - debug=False, - async_load=False, - defer_load=False, - lazy_load=False, - media=None, + assets_params=None, + rtl=False, ): - res = super()._generate_asset_nodes( - bundle, css, js, debug, async_load, defer_load, lazy_load, media + 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( @@ -29,10 +30,34 @@ class QWeb(models.AbstractModel): res += [asset.get_company_color_asset_node()] return res - def _get_asset_content(self, bundle, defer_load=False, lazy_load=False, media=None): + def _get_asset_content(self, bundle, assets_params=None): """Handle 'special' web_company_color bundle""" if bundle == "web_company_color.company_color_assets": return [], [] - return super()._get_asset_content( - bundle, defer_load=defer_load, lazy_load=lazy_load, media=media + return super()._get_asset_content(bundle, assets_params=assets_params) + + def _get_asset_nodes( + self, + bundle, + css=True, + js=True, + debug=False, + defer_load=False, + lazy_load=False, + media=None, + ): + res = super()._get_asset_nodes( + bundle, + css=css, + js=js, + debug=debug, + defer_load=defer_load, + lazy_load=lazy_load, + media=media, ) + for tag, attributes in res: + if tag == "link" and attributes.get("href", "").startswith( + "/web_company_color/static/src/scss/custom_colors." + ): + attributes.pop("type", None) + return res diff --git a/web_company_color/models/res_company.py b/web_company_color/models/res_company.py index 278e832d3..f31b2661c 100644 --- a/web_company_color/models/res_company.py +++ b/web_company_color/models/res_company.py @@ -20,13 +20,6 @@ class ResCompany(models.Model): background-color: %(color_navbar_bg)s !important; color: %(color_navbar_text)s !important; - > .o_menu_brand { - color: %(color_navbar_text)s !important; - &:hover, &:focus, &:active, &:focus:active { - background-color: %(color_navbar_bg_hover)s !important; - } - } - .show { .dropdown-toggle { background-color: %(color_navbar_bg_hover)s !important; @@ -45,6 +38,12 @@ class ResCompany(models.Model): } } } + .o_menu_brand { + color: %(color_navbar_text)s !important; + &:hover, &:focus, &:active, &:focus:active { + background-color: %(color_navbar_bg_hover)s !important; + } + } a[href], a[tabindex], @@ -100,6 +99,27 @@ class ResCompany(models.Model): --o-caret-color: %(color_button_bg)s !important; } } + .o_menu_sections .o_nav_entry { + background: %(color_navbar_bg)s !important; + background-color: %(color_navbar_bg)s !important; + color: %(color_navbar_text)s !important; + &:hover, &:focus, &:active, &:focus:active { + background-color: %(color_navbar_bg_hover)s !important; + } + } + .o_menu_sections .o-dropdown .dropdown-toggle { + background: %(color_navbar_bg)s !important; + background-color: %(color_navbar_bg)s !important; + color: %(color_navbar_text)s !important; + &:hover, &:focus, &:active, &:focus:active { + background-color: %(color_navbar_bg_hover)s !important; + } + } + .o-mail-DiscussSystray-class { + &:hover, &:focus, &:active, &:focus:active { + background-color: %(color_navbar_bg_hover)s !important; + } + } """ company_colors = fields.Serialized() @@ -218,14 +238,14 @@ class ResCompany(models.Model): ) values = { "datas": datas, - "db_datas": datas, "url": custom_url, "name": custom_url, "company_id": record.id, + "type": "binary", + "mimetype": "text/css", } if custom_attachment: custom_attachment.sudo().write(values) else: - values.update({"type": "binary", "mimetype": "text/scss"}) IrAttachmentObj.sudo().create(values) - self.env["ir.qweb"].sudo().clear_caches() + self.env.registry.clear_cache() diff --git a/web_company_color/static/description/index.html b/web_company_color/static/description/index.html index bac826421..8391fe6a3 100644 --- a/web_company_color/static/description/index.html +++ b/web_company_color/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:8a814ac88491029ca65ef378be730bd05a762604c5913f24f9cf1c6ea5b160cb +!! source digest: sha256:d3127248cefbf2ea4da8c6e1569a1a9129edd5e5d7eb612c8d805bacb56a5ab0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

This module change navbar colors based in the company logo colors.