[MIG] web_company_color: Migration to 17.0

This commit is contained in:
ArnauCForgeFlow
2024-12-18 12:37:01 +01:00
committed by ThiagoMForgeFlow
parent e9b67a47fc
commit b0ce15419a
7 changed files with 75 additions and 47 deletions

View File

@@ -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"],

View File

@@ -1,15 +1,12 @@
# Copyright 2019 Alexandre Díaz <dev@redneboa.es>
# 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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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

View File

@@ -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()

View File

@@ -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
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>