[MIG] web_company_color: Migration to 17.0

pull/3110/head
ArnauCForgeFlow 2024-12-18 12:37:01 +01:00 committed by pilarvargas-tecnativa
parent d48bee0df5
commit e6aaf45afe
12 changed files with 90 additions and 57 deletions

View File

@ -7,7 +7,7 @@ Web Company Color
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8a814ac88491029ca65ef378be730bd05a762604c5913f24f9cf1c6ea5b160cb !! source digest: sha256:d3127248cefbf2ea4da8c6e1569a1a9129edd5e5d7eb612c8d805bacb56a5ab0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@ -70,17 +70,17 @@ Authors
Contributors Contributors
------------ ------------
- Jordi Ballester Alomar <jordi.ballester@forgeflow.com> (ForgeFlow) - Jordi Ballester Alomar <jordi.ballester@forgeflow.com> (ForgeFlow)
- Lois Rilo <lois.rilo@forgeflow.com> (ForgeFlow) - Lois Rilo <lois.rilo@forgeflow.com> (ForgeFlow)
- Simone Orsi <simone.orsi@camptocamp.com> - Simone Orsi <simone.orsi@camptocamp.com>
- Iván Antón <ozono@ozonomultimedia.com> - Iván Antón <ozono@ozonomultimedia.com>
- Bernat Puig <bernat.puig@forgeflow.com> (ForgeFlow) - Bernat Puig <bernat.puig@forgeflow.com> (ForgeFlow)
- Dhara Solanki <dhara.solanki@initos.com> - Dhara Solanki <dhara.solanki@initos.com>
- `Tecnativa <https://www.tecnativa.com>`__: - `Tecnativa <https://www.tecnativa.com>`__:
- Jairo Llopis - Jairo Llopis
- Alexandre Díaz - Alexandre Díaz
- Carlos Roca - Carlos Roca
Maintainers Maintainers
----------- -----------

View File

@ -5,7 +5,7 @@
{ {
"name": "Web Company Color", "name": "Web Company Color",
"category": "web", "category": "web",
"version": "16.0.1.2.3", "version": "17.0.1.0.0",
"author": "Alexandre Díaz, Odoo Community Association (OCA)", "author": "Alexandre Díaz, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web", "website": "https://github.com/OCA/web",
"depends": ["web", "base_sparse_field"], "depends": ["web", "base_sparse_field"],

View File

@ -1,15 +1,12 @@
# Copyright 2019 Alexandre Díaz <dev@redneboa.es> # Copyright 2019 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # 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 from .models.res_company import URL_BASE
def uninstall_hook(cr, registry): def uninstall_hook(env):
env = api.Environment(cr, SUPERUSER_ID, {})
env["ir.attachment"].search([("url", "=like", "%s%%" % URL_BASE)]).unlink() env["ir.attachment"].search([("url", "=like", "%s%%" % URL_BASE)]).unlink()
def post_init_hook(cr, registry): def post_init_hook(env):
env = api.Environment(cr, SUPERUSER_ID, {})
env["res.company"].search([]).scss_create_or_update_attachment() env["res.company"].search([]).scss_create_or_update_attachment()

View File

@ -20,7 +20,8 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:web_company_color.view_company_form #: model_terms:ir.ui.view,arch_db:web_company_color.view_company_form
msgid "" msgid ""
"<span class=\"fa fa-info fa-2x me-2\"/>\n" "<span class=\"fa fa-info fa-2x me-2\"/>\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." " the page."
msgstr "" msgstr ""
"<span class=\"fa fa-info fa-2x me-2\"/>\n" "<span class=\"fa fa-info fa-2x me-2\"/>\n"

View File

@ -13,8 +13,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 3.8\n" "X-Generator: Weblate 3.8\n"
#. module: web_company_color #. module: web_company_color

View File

@ -20,7 +20,8 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:web_company_color.view_company_form #: model_terms:ir.ui.view,arch_db:web_company_color.view_company_form
msgid "" msgid ""
"<span class=\"fa fa-info fa-2x me-2\"/>\n" "<span class=\"fa fa-info fa-2x me-2\"/>\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." " the page."
msgstr "" msgstr ""
"<span class=\"fa fa-info fa-2x me-2\"/>\n" "<span class=\"fa fa-info fa-2x me-2\"/>\n"

View File

@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 16.0\n" "Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"

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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.http import request 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): class AssetsBundleCompanyColor(AssetsBundle):
@ -17,6 +17,4 @@ class AssetsBundleCompanyColor(AssetsBundle):
company_id = ( company_id = (
self.env["res.company"].browse(active_company_id) or self.env.company self.env["res.company"].browse(active_company_id) or self.env.company
) )
asset = ScssStylesheetAsset(self, url=company_id.scss_get_url()) return company_id.scss_get_url()
compiled = self.compile_css(asset.compile, asset.get_source())
return "style", {}, compiled

View File

@ -8,19 +8,20 @@ from .assetsbundle import AssetsBundleCompanyColor
class QWeb(models.AbstractModel): class QWeb(models.AbstractModel):
_inherit = "ir.qweb" _inherit = "ir.qweb"
def _generate_asset_nodes_cache( def _generate_asset_links_cache(
self, self,
bundle, bundle,
css=True, css=True,
js=True, js=True,
debug=False, assets_params=None,
async_load=False, rtl=False,
defer_load=False,
lazy_load=False,
media=None,
): ):
res = super()._generate_asset_nodes( res = super()._generate_asset_links_cache(
bundle, css, js, debug, async_load, defer_load, lazy_load, media bundle,
css=css,
js=js,
assets_params=assets_params,
rtl=rtl,
) )
if bundle == "web_company_color.company_color_assets": if bundle == "web_company_color.company_color_assets":
asset = AssetsBundleCompanyColor( asset = AssetsBundleCompanyColor(
@ -29,10 +30,34 @@ class QWeb(models.AbstractModel):
res += [asset.get_company_color_asset_node()] res += [asset.get_company_color_asset_node()]
return res 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""" """Handle 'special' web_company_color bundle"""
if bundle == "web_company_color.company_color_assets": if bundle == "web_company_color.company_color_assets":
return [], [] return [], []
return super()._get_asset_content( return super()._get_asset_content(bundle, assets_params=assets_params)
bundle, defer_load=defer_load, lazy_load=lazy_load, media=media
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; background-color: %(color_navbar_bg)s !important;
color: %(color_navbar_text)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 { .show {
.dropdown-toggle { .dropdown-toggle {
background-color: %(color_navbar_bg_hover)s !important; 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[href],
a[tabindex], a[tabindex],
@ -100,6 +99,27 @@ class ResCompany(models.Model):
--o-caret-color: %(color_button_bg)s !important; --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() company_colors = fields.Serialized()
@ -218,14 +238,14 @@ class ResCompany(models.Model):
) )
values = { values = {
"datas": datas, "datas": datas,
"db_datas": datas,
"url": custom_url, "url": custom_url,
"name": custom_url, "name": custom_url,
"company_id": record.id, "company_id": record.id,
"type": "binary",
"mimetype": "text/css",
} }
if custom_attachment: if custom_attachment:
custom_attachment.sudo().write(values) custom_attachment.sudo().write(values)
else: else:
values.update({"type": "binary", "mimetype": "text/scss"})
IrAttachmentObj.sudo().create(values) IrAttachmentObj.sudo().create(values)
self.env["ir.qweb"].sudo().clear_caches() self.env.registry.clear_cache()

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8a814ac88491029ca65ef378be730bd05a762604c5913f24f9cf1c6ea5b160cb !! source digest: sha256:d3127248cefbf2ea4da8c6e1569a1a9129edd5e5d7eb612c8d805bacb56a5ab0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/17.0/web_company_color"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_company_color"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/17.0/web_company_color"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_company_color"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module change navbar colors based in the company logo colors.</p> <p>This module change navbar colors based in the company logo colors.</p>