Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

CSS not getting applied whensaved in external file

Subscribe

Get notified when there's activity on this post

This question has been flagged
templateweblayoutcssassetsbackendOdoo19.0
2 Replies
184 Views
Avatar
Sofia Ingalls

I am trying to create a simple dashboard using QWEB. So far, I have been able to create a simple example that works and launches as a standalone page with some ORM interaction.  Here's a truncated version of my script that works:


<?xml version="1.0" encoding="UTF-8"?>

<odoo>

​<template id="my_dashboard_meta" inherit_id="web.layout">

​ ​<xpath expr="//head" position="inside">

​​ ​<meta name="viewport" content="width=device-width, initial-scale=1.0" />

​ ​</xpath>

​</template>


​<template id="kanban_dashboard" name="My Dashboard">

​<t t-call="web.layout">

​ ​<style>

​ ​ ​@font-face {

​ ​ ​ ​font-family: LCD;

​ ​ ​ ​src: url("/my_dashboard/static/src/fonts/lcd-regular-webfont.ttf");

​ ​ ​}


​ ​ ​html {

​ ​ ​ ​font-family: LCD, Times, serif;

​ ​ ​ ​overflow: hidden;

​ ​ ​ ​margin: 0;

​ ​ ​ ​padding: 0;

​ ​ ​ ​min-height: 100vh;

​ ​ ​ ​width: 100%;

​ ​ ​ ​background-image: url("/my_dashboard/static/src/images/bg.jpg");

​ ​ ​ ​background-size: cover;

​ ​ ​ ​background-position: center;

​ ​ ​ ​background-repeat: no-repeat;

​ ​ ​}


​ ​ ​.kanban-4 {

​ ​ ​ ​width: 25%;

​ ​ ​ ​align-items: center;

​ ​ ​text-align: center;

​ ​ ​}


​ ​ ​.kanban-card {

​ ​ ​ ​ border: 1px solid #ddd;

​ ​ ​ ​ border-radius: 8px;

​ ​ ​ ​ overflow: hidden;

​ ​ ​ ​ background: #fff;

​ ​ ​ ​ display: flex;

​ ​ ​ ​ flex-direction: column;

​ ​ ​ ​ align-items: center;

​ ​ ​ ​ text-align: center;

​ ​ ​ ​ margin-bottom: 30px;

​ ​ ​}


​ ​ ​ @media (max-width: 1200px) {

​ ​ ​ ​ html {

​ ​ ​ ​ ​ overflow-y: scroll;

​ ​ ​ ​}

​ ​ ​ ​.kanban-4 {

​ ​ ​ ​ ​width: 30%;

​ ​ ​ ​}

​ ​ ​ }

​ ​ ​

​ ​ ​@media (max-width: 600px) {

​ ​ ​ ​ .kanban-4 {

​ ​ ​ ​ ​ width: 90%;

​ ​ ​ ​ }

​ ​ ​ }

​ ​ </style>



​ ​<p>Example Entry</p>

​ ​<div>

​ ​ ​ <t t-set="action_quotations" t-value="request.env.ref('sale.action_quotations', False)" />

​ ​ ​ <t t-if="action_quotations">

​ ​ ​ ​ <div class="kanban-card">

​ ​ ​ ​ ​<a t-att-href="'/web#action=%s' % action_quotations.id">

​ ​ ​ ​ ​ ​<img src="/my_dashboard/static/src/images/rfq_icon.png"

​ ​ ​ ​ alt="Pending Orders" />

​ ​ ​ ​ ​ ​<div class="content">

​ ​ ​ ​ ​ ​ ​<p>Pending Orders</p>

​ ​ ​ ​ ​ </div>

​ ​ ​ ​ ​</a>

​ ​ ​ ​ </div>

​ ​ ​ </t>

​ ​ </div>

​</t>

​</template>

</odoo>


However, while trying to refine the template by moving the CSS out into a separate file, it does not seem to work. It is clearly listed in the manifest like so:

{

​ 'name': 'My Dashboard',

​ 'version': '1.0',

​ 'category': 'Tools',

​ 'summary': 'Custom Dashboard',

​ 'author': 'Sofia',

​ 'depends': ['base', 'web', 'sale', 'crm', 'stock', 'purchase'],

​ 'data': [

​ ​ 'security/ir.model.access.csv',

​ ​ 'views/templates.xml',

​ ​ 'views/menus.xml',

​ ​ 'views/actions.xml',

​],

​ 'assets': {

​ ​ 'web.assets_backend': [

​ ​ ​'my_dashboard/static/src/css/dashboard.css',

​ ​ ],

​ },

​ 'installable': True,

​ 'application': True,

}


Am I missing some step to get the CSS recognized?

0
Avatar
Discard
Kunjan Patel

You're using <t t-call="web.layout"> which is a frontend/website template, but your CSS is in web.assets_backend (backend bundle). This is the mismatch!

'assets': {
'web.assets_frontend': [ # Changed from backend to frontend!
'my_dashboard/static/src/scss/dashboard.scss', # Also use SCSS
],
},
You were using web.layout (frontend) but loading CSS in web.assets_backend (backend) → CSS never loaded!

Sofia Ingalls
Author

Hello again, Kunjan. I was so hopeful when I read your comment this time. It sounded so promising. But alas, it still doesn't work. For good measure, I had uninstalled the module, cleared the browser cache, restarted Odoo, updated apps, then re-installed it and regenerated assets as well. Still, nada.

Instead of web.layout, should I try some other model, perhaps?

I do appreciate your tireless help, but this seems a real conundrum.

Kunjan Patel

Quick Debug Steps Most likely issue: You're missing a controller - the template won't render without one.

Create controllers/main.py:
from odoo import http
class MyDashboard(http.Controller):
@http.route('/my_dashboard', type='http', auth='user', website=True)
def index(self, **kw):
return http.request.render('my_dashboard.kanban_dashboard')

Update __manifest__.py: Add 'website' to depends, and add '__init__.py' root file with from . import controllers.

Test: Add <div style="background:red;padding:50px">TEST</div> at top of template. If you DON'T see a red box, the template isn't rendering at all (controller issue). If you DO see red
box but no CSS, then it's the asset bundle. Access via: http://your-odoo/my_dashboard

Sofia Ingalls
Author

Hi Kunjan. It does have a controller and the page does load and render perfectly - but only when the CSS block is inside the template within style tags - like I had mentioned in my OP. If the CSS is removed to an external file, the page still renders, but without the proper styling.

Nevertheless, since it already had a header template for the meta tag (please see the OP) I tried inserting the style link to the CSS there and it worked.

<template id="my_dashboard_meta" inherit_id="web.layout">
​ <xpath expr="//head" position="inside">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="my_dashboard/static/src/css/dashboard.css"></link>
​</xpath>
​</template>

Is this a legal insertion in Odoo, would you know?

Sofia Ingalls
Author

Hi Kunjan, and thank you for your prompt reply. It is truly appreciated.

I had performed all the steps that you had recommended (except refactoring the css specificity) as follows:

  Step 1: Ensure Correct File Structure (changed CSS to SCSS, file and folder name)

  Step 2: Correct Manifest Configuration

  Step 4: Critical - Reload Assets

  # 1. Restart Odoo server

  # 2. Upgrade module (MOST IMPORTANT!)

  # 3. Clear browser cache: Ctrl+Shift+R

  # 4. Regenerate assets bundles


But sadly, it still did not load (confirmed with dev tools on the browser). Could the issue possibly be with the template? Perhaps it is not inheriting the correct model, or there is some incompatibility with the structure, causing it not to warrant a CSS to be loaded? There is another header template at the top for including meta tags. Could that be an issue?

Kunjan Patel

Yes, this is completely legal and standard in Odoo 19.

Inheriting web.layout to add SCSS links in the <head> is the correct approach for controller-based pages. Your implementation is proper and will work perfectly in Odoo 19.

However, Odoo 19's recommended best practice is using asset bundles in __manifest__.py:
'assets': {
'web.assets_frontend': [
'my_dashboard/static/src/scss/dashboard.scss',
],
}

Both methods are valid in Odoo 19. Your web.layout inheritance works fine, but asset bundles provide better performance.

Avatar
Kunjan Patel
Best Answer
Hello, Sofia Ingalls
I hope you are doing well,

SOLUTION: External CSS Not Loading in Odoo 19

Quick Debug Steps Most likely issue:
You're missing a controller - the template won't render without one.

Create controllers/main.py:

from odoo import http

class MyDashboard(http.Controller):

@http.route('/my_dashboard', type='http', auth='user', website=True)

def index(self, **kw):

return http.request.render('my_dashboard.kanban_dashboard')

Update __manifest__.py: Add 'website' to depends, and add '__init__.py' root file with 
from . import controllers.

Test: Add <div style="background:red;padding:50px">TEST</div> at top of template. If you DON'T see a red box, the template isn't rendering at all (controller issue). If you DO see red

box but no CSS, then it's the asset bundle. Access via: http://your-odoo/my_dashboard

Hope this information helps you

Thanks & Regards,
Kunjan Patel
0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
What is the difference between 'report_assets_common' and 'report_assets_pdf'
reports template css assets odoo16features
Avatar
Avatar
Avatar
Avatar
3
फ़र॰ 24
9708
What is the difference between 'report_assets_common' and 'report_assets_pdf' Solved
reports template css assets odoo16features
Avatar
Avatar
1
सित॰ 23
3932
External ID not found in the system: web.assets_backend
theme assets backend
Avatar
Avatar
Avatar
2
मार्च 23
10744
Bug in backend theme where hamburger menu doesn't open the second time. Does anyone know how to fix this?
menu css theme backend
Avatar
Avatar
Avatar
Avatar
3
अग॰ 21
5717
Odoo 11.0 load css/scripts or something else into <head> only when a template is rendered
template assets frontend odoo11
Avatar
0
दिस॰ 18
3864
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now