Skip to content

Commit b0ce154

Browse files
ArnauCForgeFlowThiagoMForgeFlow
authored andcommitted
[MIG] web_company_color: Migration to 17.0
1 parent e9b67a4 commit b0ce154

File tree

7 files changed

+75
-47
lines changed

7 files changed

+75
-47
lines changed

web_company_color/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "Web Company Color",
77
"category": "web",
8-
"version": "16.0.1.2.3",
8+
"version": "17.0.1.0.0",
99
"author": "Alexandre Díaz, Odoo Community Association (OCA)",
1010
"website": "https://github.com/OCA/web",
1111
"depends": ["web", "base_sparse_field"],

web_company_color/hooks.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# Copyright 2019 Alexandre Díaz <dev@redneboa.es>
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3-
from odoo import SUPERUSER_ID, api
43

54
from .models.res_company import URL_BASE
65

76

8-
def uninstall_hook(cr, registry):
9-
env = api.Environment(cr, SUPERUSER_ID, {})
7+
def uninstall_hook(env):
108
env["ir.attachment"].search([("url", "=like", "%s%%" % URL_BASE)]).unlink()
119

1210

13-
def post_init_hook(cr, registry):
14-
env = api.Environment(cr, SUPERUSER_ID, {})
11+
def post_init_hook(env):
1512
env["res.company"].search([]).scss_create_or_update_attachment()

web_company_color/migrations/16.0.1.2.1/post-migration.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

web_company_color/models/assetsbundle.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33
from odoo.http import request
44

5-
from odoo.addons.base.models.assetsbundle import AssetsBundle, ScssStylesheetAsset
5+
from odoo.addons.base.models.assetsbundle import AssetsBundle
66

77

88
class AssetsBundleCompanyColor(AssetsBundle):
@@ -17,6 +17,4 @@ def get_company_color_asset_node(self):
1717
company_id = (
1818
self.env["res.company"].browse(active_company_id) or self.env.company
1919
)
20-
asset = ScssStylesheetAsset(self, url=company_id.scss_get_url())
21-
compiled = self.compile_css(asset.compile, asset.get_source())
22-
return "style", {}, compiled
20+
return company_id.scss_get_url()

web_company_color/models/ir_qweb.py

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88
class QWeb(models.AbstractModel):
99
_inherit = "ir.qweb"
1010

11-
def _generate_asset_nodes_cache(
11+
def _generate_asset_links_cache(
1212
self,
1313
bundle,
1414
css=True,
1515
js=True,
16-
debug=False,
17-
async_load=False,
18-
defer_load=False,
19-
lazy_load=False,
20-
media=None,
16+
assets_params=None,
17+
rtl=False,
2118
):
22-
res = super()._generate_asset_nodes(
23-
bundle, css, js, debug, async_load, defer_load, lazy_load, media
19+
res = super()._generate_asset_links_cache(
20+
bundle,
21+
css=css,
22+
js=js,
23+
assets_params=assets_params,
24+
rtl=rtl,
2425
)
2526
if bundle == "web_company_color.company_color_assets":
2627
asset = AssetsBundleCompanyColor(
@@ -29,10 +30,34 @@ def _generate_asset_nodes_cache(
2930
res += [asset.get_company_color_asset_node()]
3031
return res
3132

32-
def _get_asset_content(self, bundle, defer_load=False, lazy_load=False, media=None):
33+
def _get_asset_content(self, bundle, assets_params=None):
3334
"""Handle 'special' web_company_color bundle"""
3435
if bundle == "web_company_color.company_color_assets":
3536
return [], []
36-
return super()._get_asset_content(
37-
bundle, defer_load=defer_load, lazy_load=lazy_load, media=media
37+
return super()._get_asset_content(bundle, assets_params=assets_params)
38+
39+
def _get_asset_nodes(
40+
self,
41+
bundle,
42+
css=True,
43+
js=True,
44+
debug=False,
45+
defer_load=False,
46+
lazy_load=False,
47+
media=None,
48+
):
49+
res = super()._get_asset_nodes(
50+
bundle,
51+
css=css,
52+
js=js,
53+
debug=debug,
54+
defer_load=defer_load,
55+
lazy_load=lazy_load,
56+
media=media,
3857
)
58+
for tag, attributes in res:
59+
if tag == "link" and attributes.get("href", "").startswith(
60+
"/web_company_color/static/src/scss/custom_colors."
61+
):
62+
attributes.pop("type", None)
63+
return res

web_company_color/models/res_company.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ class ResCompany(models.Model):
2020
background-color: %(color_navbar_bg)s !important;
2121
color: %(color_navbar_text)s !important;
2222
23-
> .o_menu_brand {
24-
color: %(color_navbar_text)s !important;
25-
&:hover, &:focus, &:active, &:focus:active {
26-
background-color: %(color_navbar_bg_hover)s !important;
27-
}
28-
}
29-
3023
.show {
3124
.dropdown-toggle {
3225
background-color: %(color_navbar_bg_hover)s !important;
@@ -45,6 +38,12 @@ class ResCompany(models.Model):
4538
}
4639
}
4740
}
41+
.o_menu_brand {
42+
color: %(color_navbar_text)s !important;
43+
&:hover, &:focus, &:active, &:focus:active {
44+
background-color: %(color_navbar_bg_hover)s !important;
45+
}
46+
}
4847
4948
a[href],
5049
a[tabindex],
@@ -100,6 +99,27 @@ class ResCompany(models.Model):
10099
--o-caret-color: %(color_button_bg)s !important;
101100
}
102101
}
102+
.o_menu_sections .o_nav_entry {
103+
background: %(color_navbar_bg)s !important;
104+
background-color: %(color_navbar_bg)s !important;
105+
color: %(color_navbar_text)s !important;
106+
&:hover, &:focus, &:active, &:focus:active {
107+
background-color: %(color_navbar_bg_hover)s !important;
108+
}
109+
}
110+
.o_menu_sections .o-dropdown .dropdown-toggle {
111+
background: %(color_navbar_bg)s !important;
112+
background-color: %(color_navbar_bg)s !important;
113+
color: %(color_navbar_text)s !important;
114+
&:hover, &:focus, &:active, &:focus:active {
115+
background-color: %(color_navbar_bg_hover)s !important;
116+
}
117+
}
118+
.o-mail-DiscussSystray-class {
119+
&:hover, &:focus, &:active, &:focus:active {
120+
background-color: %(color_navbar_bg_hover)s !important;
121+
}
122+
}
103123
"""
104124

105125
company_colors = fields.Serialized()
@@ -218,14 +238,14 @@ def scss_create_or_update_attachment(self):
218238
)
219239
values = {
220240
"datas": datas,
221-
"db_datas": datas,
222241
"url": custom_url,
223242
"name": custom_url,
224243
"company_id": record.id,
244+
"type": "binary",
245+
"mimetype": "text/css",
225246
}
226247
if custom_attachment:
227248
custom_attachment.sudo().write(values)
228249
else:
229-
values.update({"type": "binary", "mimetype": "text/scss"})
230250
IrAttachmentObj.sudo().create(values)
231-
self.env["ir.qweb"].sudo().clear_caches()
251+
self.env.registry.clear_cache()

web_company_color/static/description/index.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
/*
1010
:Author: David Goodger (goodger@python.org)
11-
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
11+
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15-
Despite the name, some widely supported CSS2 features are used.
1615
1716
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1817
customize this style sheet.
@@ -275,7 +274,7 @@
275274
margin-left: 2em ;
276275
margin-right: 2em }
277276

278-
pre.code .ln { color: gray; } /* line numbers */
277+
pre.code .ln { color: grey; } /* line numbers */
279278
pre.code, code { background-color: #eeeeee }
280279
pre.code .comment, code .comment { color: #5C6576 }
281280
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@
301300
span.pre {
302301
white-space: pre }
303302

304-
span.problematic, pre.problematic {
303+
span.problematic {
305304
color: red }
306305

307306
span.section-subtitle {
@@ -432,9 +431,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
432431
<div class="section" id="maintainers">
433432
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
434433
<p>This module is maintained by the OCA.</p>
435-
<a class="reference external image-reference" href="https://odoo-community.org">
436-
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
437-
</a>
434+
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
438435
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
439436
mission is to support the collaborative development of Odoo features and
440437
promote its widespread use.</p>

0 commit comments

Comments
 (0)