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/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..486145de6 100644 --- a/web_company_color/static/description/index.html +++ b/web_company_color/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. -Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +274,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code { margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +300,7 @@ span.option { span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { @@ -432,9 +431,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

Maintainers

This module is maintained by the OCA.

- -Odoo Community Association - +Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.