From 3f547613b4d0588f13c886345e4c9fd21f8141b3 Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Wed, 15 Jul 2026 09:40:13 +0200 Subject: [PATCH] [18.0][FIX] web_company_color: regenerate legacy color attachments on upgrade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Databases upgraded from older versions keep the per-company color attachments in the legacy format (raw SCSS, application/octet-stream). The module now compiles the SCSS server-side and serves the attachment directly as a stylesheet, so browsers refuse the legacy ones under strict MIME checking and company colors silently stop applying. Only post_init_hook (fresh installs) regenerates them — add a post-migration so upgrades do too. --- web_company_color/__manifest__.py | 2 +- .../migrations/18.0.1.1.1/post-migration.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 web_company_color/migrations/18.0.1.1.1/post-migration.py diff --git a/web_company_color/__manifest__.py b/web_company_color/__manifest__.py index 1f30c4e8af3..1a2280bed99 100644 --- a/web_company_color/__manifest__.py +++ b/web_company_color/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Web Company Color", "category": "web", - "version": "18.0.1.1.0", + "version": "18.0.1.1.1", "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/migrations/18.0.1.1.1/post-migration.py b/web_company_color/migrations/18.0.1.1.1/post-migration.py new file mode 100644 index 00000000000..0e510f76a39 --- /dev/null +++ b/web_company_color/migrations/18.0.1.1.1/post-migration.py @@ -0,0 +1,22 @@ +# Copyright NuoBiT Solutions - Eric Antones +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +from odoo import SUPERUSER_ID, api + + +def migrate(cr, version): + """Regenerate the per-company color attachments in the current format. + + Databases upgraded from older versions still carry the color + attachments in the legacy format (raw SCSS content, mimetype + ``application/octet-stream``). The current module compiles the SCSS + server-side and serves the attachment URL directly as a stylesheet, + so it needs compiled CSS with mimetype ``text/css`` — browsers refuse + the legacy attachments under strict MIME checking and company colors + silently stop applying. Only the ``post_init_hook`` (fresh installs) + regenerates them; upgrades never did. Idempotent: regenerating an + up-to-date attachment rewrites it with identical semantics. + """ + if not version: + return + env = api.Environment(cr, SUPERUSER_ID, {}) + env["res.company"].search([]).scss_create_or_update_attachment()