Skip to Content
Logo of RG Logo of RG
  • Home
  • Shop
  • Events
  • Courses
  • Company
    • News
    • Success Stories
  • Odoo Docs 19
  • Appointment
  • Jobs
  • Contact us
  • 0
  • 0
  • +1 555-555-5556
  • Sign in
Logo of RG Logo of RG
  • 0
  • 0
    • Home
    • Shop
    • Events
    • Courses
    • Company
      • News
      • Success Stories
    • Odoo Docs 19
    • Appointment
    • Jobs
    • Contact us
  • +1 555-555-5556
  • Sign in
Odoo Docs 19
Home Components Guides Classes Search
418 components
Overlay
  • Accordion Item
  • Barcode Dialog
  • Bottom Sheet
  • Calendar Common Popover
  • Calendar Year Popover
  • Confirmation Dialog
  • Date Time Picker Popover
  • dialog
  • Domain Selector Dialog
  • Dropdown
  • Dropdown Group
  • Dropdown Item
  • Dropdown Popover
  • Error504 Dialog
  • Error Dialog
  • Export Data Dialog
  • Expression Editor Dialog
  • Form Error Dialog
  • Form View Dialog
  • Kanban Column Examples Dialog
  • Kanban Cover Image Dialog
  • Kanban Dropdown Menu Wrapper
  • List Confirmation Dialog
  • Model Field Selector Popover
  • Multi Create Popover
  • Multi Currency Popover
  • popover
  • Redirect Warning Dialog
  • Res User Group Ids Popover
  • Scss Error Display
  • Select Create
  • Select Create Dialog
  • Session Expired Dialog
  • Signature Dialog
  • Warning Dialog
  1. Components
  2. Scss Error Display
services overlay

Scss Error Display

Odoo 19 services — Scss Error Display (core)

Live preview Interactive
Source excerpt web/static/src/core/errors/scss_error_dialog.js
import { browser } from "@web/core/browser/browser";
import { registry } from "@web/core/registry";
import { _t, translationIsReady } from "@web/core/l10n/translation";
import { getOrigin } from "@web/core/utils/urls";

const scssErrorNotificationService = {
    dependencies: ["notification"],
    start(env, { notification }) {
        const origin = getOrigin();
        // Iframe with src "about:blank" origin isn't a valid base URL.
        if (browser.location.origin === "null") {
            return;
        }
        const assets = [...document.styleSheets].filter((sheet) => {
            return (
                sheet.href?.includes("/web") &&
                sheet.href?.includes("/assets/") &&
                // CORS security rules don't allow reading content in JS
                new URL(sheet.href, browser.location.origin).origin === origin
            );
        });
        translationIsReady.then(() => {
            for (const asset of assets) {
                let cssRules;
                try {
                    // The filter above isn't enough to protect against CORS errors when reading
                    // the cssRules property. Indeed, it seems that if the protocol is http, reading
                    // that property can also trigger a CORS error, even if the origin is the same.
                    // Anyway, we never want this line to crash, so we protect it.
                    // See opw 3746910.
                    cssRules = asset.cssRules;
                } catch {
                    continue;
                }
                const lastRule = cssRules?.[cssRules?.length - 1];
                if (lastRule?.selectorText === "css_error_message") {
                    const message = _t(
                        "The style compilation failed. This is an administrator or developer error that must be fixed for the entire database before continuing working. See browser console or server logs for details."
                    );
                    notification.add(message, {
                        title: _t("Style error"),
                        sticky: true,
                        type: "danger",
                    });
                    console.log(
                        lastRule.style.content
                            .replaceAll("\\a", "\n")
                            .replaceAll("\\*", "*")
                            .replaceAll(`\\"`, `"`)
                    );
                }
            }
        });
    },
};
registry.category("services").add("scss_error_display", scssErrorNotificationService);
Registry / API
Registry name
scss_error_display
Category
services
Module
web
Slug
scss-error-display
Nav group
overlay
Follow us

250 Executive Park Blvd, Suite 3400
San Francisco CA 94134

  • +1 555-555-5556
  • info@yourcompany.example.com
Copyright © Company name
Powered by Odoo - The #1 Open Source eCommerce