mirror of https://github.com/OCA/web.git
[MIG] web_company_color: Migration to 17.0
parent
d48bee0df5
commit
e6aaf45afe
|
@ -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
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -20,7 +20,8 @@ msgstr ""
|
|||
#: model_terms:ir.ui.view,arch_db:web_company_color.view_company_form
|
||||
msgid ""
|
||||
"<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."
|
||||
msgstr ""
|
||||
"<span class=\"fa fa-info fa-2x me-2\"/>\n"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,7 +20,8 @@ msgstr ""
|
|||
#: model_terms:ir.ui.view,arch_db:web_company_color.view_company_form
|
||||
msgid ""
|
||||
"<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."
|
||||
msgstr ""
|
||||
"<span class=\"fa fa-info fa-2x me-2\"/>\n"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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()
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<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&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>
|
||||
|
|
Loading…
Reference in New Issue