Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

OWL Component Not Rendering in Custom Layout (Odoo 18) — Likely XML Template Issue

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
javascriptdevelopmentprojectdebug
1 Odpowiedz
3513 Widoki
Awatar
Kvrolito

🔧 OWL Component Not Rendering in Custom Layout (Odoo 18) — Likely XML Template Issue

Hello everyone,

I'm currently working on Odoo 18 and trying to render a simple OWL component inside a custom dashboard layout. Despite successfully loading all related JS files, the component does not appear in the UI, and I suspect the issue lies in how the XML template is handled.

📁 Project Structure

My layout is defined in:

my_module/static/src/views/dashboard_page_layout.xml

My JS files are located in:

my_module/static/src/js/

📦 Files

HelloBox.js

/** @odoo-module **/

import { Component, xml } from '@odoo/owl';

export class HelloBox extends Component {}

HelloBox.template = xml`
  <div class="hello-box">
    <h1><t t-esc="props.title"/></h1>
    <button t-on-click="sayHello">Click me</button>
  </div>
`;

HelloBox.props = {
  title: { type: String },
};

HelloBox.prototype.sayHello = function () {
  alert('Hello from OWL!');
};

HelloBox.xml

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
  <t t-name="my_module.HelloBox" owl="1">
    <div class="p-3">
      <p><t t-out="props.title"/></p>
      <button>Click me</button>
    </div>
  </t>
</templates>

init_owl.js

/** @odoo-module **/

import { mount, whenReady } from '@odoo/owl';
import { HelloBox } from './HelloBox';

whenReady(() => {
  const root = document.getElementById('hello-box-root');
  console.log('Mounting HelloBox in:', root);

  if (root) {
    mount(HelloBox, {
      target: root,
      props: { title: 'Witaj z OWL!' },
    });
  }
});

In my dashboard_page_layout.xml, I manually placed:

<div id="hello-box-root"></div>

🧩 Problem Focus

✅ The JS loads successfully, console.log confirms the mount target exists, and the component code is correct.

❌ The XML template seems to be the weak point — I suspect it may not be loaded or registered correctly, despite being included in the assets.

In some cases I even get:

TypeError: Cannot read properties of undefined (reading 'defaultProps')

Which usually indicates OWL is trying to mount an incomplete or undefined component — possibly due to the XML template not being properly compiled or injected.

📜 __manifest__.py

'assets': {
    'web.assets_frontend': [
        'my_module/static/src/js/HelloBox.xml',
        'my_module/static/src/js/HelloBox.js',
        'my_module/static/src/js/init_owl.js',
    ],
},

I've also tried adding the XML to web.assets_qweb, web.assets_backend, and changing the load order, but the issue remains.

🙏 What I'm Looking For

  • How should XML templates be properly registered in OWL/Odoo 18 when working with web.assets_frontend?
  • Do I need to explicitly register or reference them in a different way?
  • Is there anything missing to make this work with t-name="my_module.HelloBox"?
  • Is using xml\template`` inside the JS file the preferred approach instead?

Any guidance would be highly appreciated.

Thanks in advance for your support!

Karol


0
Awatar
Odrzuć
Kvrolito
Autor


Unfortunately, that’s not the case. While I’ve successfully used inline XML templates, that’s not the approach I want to take. I’d like to define my OWL templates in separate XML files so that I can pass props and create dynamic, reusable components.

🧩 Template File: owl_templates.xml

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
  <t t-name="my_folder.owl_main_component" owl="1">
    <div>
      <h3>This is rendered using OWL</h3>
    </div>
    <!-- I intentionally commented out the <t> tag earlier to test loading -->
  </t>
</templates>

🧠 Component File: owl_component.js

/** @odoo-module **/

import { Component, mount, xml, whenReady } from '@odoo/owl';
import { templates } from '@web/core/assets';

export class OwlMainComponent extends Component {}

OwlMainComponent.template = 'my_folder.owl_main_component';

// VERSION 1: await template loading inside whenReady
whenReady(async () => {
	await templates;
	const element = document.getElementById('hello-box-root');
	if (element) {
		mount(OwlMainComponent, element);
	} else {
		console.warn('❌ Missing #hello-box-root');
	}
});

// VERSION 2: naive sync mount
// const element = document.getElementById('hello-box-root');
// mount(OwlMainComponent, element);

// VERSION 3: basic whenReady
// whenReady(() => {
// 	const element = document.getElementById('hello-box-root');
// 	if (element) {
// 		mount(OwlMainComponent, element, { templates });
// 	}
// });

🔍 Investigation So Far

When I intentionally break the XML file (e.g. by removing a <t>), Odoo correctly throws an error — which proves the XML is found and parsed.

I also inspected the compiled web.assets_frontend_lazy.js. It turns out:

  • The component is mounted around line 97278
  • The XML template is only registered around line 104900

This confirms the component tries to render before the template is available.

🧪 Asset Load Order (Manifest)

To fix this, I tried forcing the load order using before and prepend:

'web.assets_frontend': [
    # ('prepend', 'my_folder/static/src/js/owl_templates.xml'),
    # ('before', 'my_folder/static/src/js/owl_component.js',
    #           'my_folder/static/src/js/owl_templates.xml'),
    ('before', 'my_folder/static/src/js/owl_templates.xml', 
               'my_folder/static/src/js/owl_component.js'),
]

However, every attempt resulted in an error saying either the XML or JS file could not be found — depending on which directive I used.

🆘 Summary

At this point I’ve tried every variation I could think of. It’s very frustrating that something as basic as loading a QWeb XML file into an OWL component doesn't work as expected.

If anyone has had success with a similar setup or knows what I might be doing wrong — I’d deeply appreciate your help 🙏

Awatar
D Enterprise
Najlepsza odpowiedź

Hii

__manifest__.py

{ "name": "Custom OWL Dashboard", "version": "1.0", "depends": ["base", "web"], "assets": { "web.assets_frontend": [ "my_module/static/src/js/HelloBox.js", "my_module/static/src/js/init_owl.js", ], }, "data": [ "views/dashboard_menu.xml", ], "installable": True, "application": True, }

HelloBox.js

my_module/static/src/js/HelloBox.js

/** @odoo -module **/ import { Component, xml } from "@odoo/owl"; export class HelloBox extends Component { static template = xml` <div class="hello-box bg-light p-3 rounded shadow"> <h2 class="mb-3"><t t-esc="props.title"/></h2> <button class="btn btn-primary" t-on-click="sayHello">Click me</button> </div> `; static props = { title: { type: String }, }; sayHello() { alert("Hello from OWL!"); } }

init_owl.js

my_module/static/src/js/init_owl.js

/** @odoo -module **/ import { mount, whenReady } from "@odoo/owl"; import { HelloBox } from "./HelloBox"; whenReady(() => { const root = document.getElementById("hello-box-root"); console.log("📦 Mounting HelloBox into", root); if (root) { mount(HelloBox, { target: root, props: { title: "Hello from OWL!", }, }); } else { console.warn("⚠️ Element #hello-box-root not found."); } });

dashboard_menu.xml

my_module/views/dashboard_menu.xml


<odoo> <template id="assets_backend" inherit_id="web.assets_backend" name="OWL Dashboard Assets"> <xpath expr="." position="inside"> <link rel="stylesheet" href="/web/static/lib/bootstrap/css/bootstrap.min.css"/> </xpath> </template> <record id="action_dashboard_hello" model="ir.actions.client"> <field name="name">OWL Dashboard</field> <field name="tag">hello_dashboard</field> </record> <menuitem id="menu_owl_dashboard_root" name="OWL Dashboard" sequence="10"/> <menuitem id="menu_owl_dashboard" parent="menu_owl_dashboard_root" name="Hello" action="action_dashboard_hello"/> </odoo>

JS Controller (Frontend Mount)

You need to register your OWL component on that page. Add this file:

my_module/static/src/js/dashboard_controller.js (optional if you're using OWL directly)

If you're using the tag 'hello_dashboard', register it using a JS client action — or skip that if you're directly including the root container via another QWeb view.

i hope it is usefull

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
How to hide the title or the close (X) button from a dialogService dialog?
javascript development debug
Awatar
Awatar
2
wrz 25
905
Error with rpc call
javascript development function debug
Awatar
Awatar
Awatar
2
lip 25
1818
Custom Cards Payment Module: POS Payment Summary Not Updating with Installments
javascript development sales project
Awatar
Awatar
2
lut 25
2187
Testing of computed field in Odoo 18 extension dev
development debug
Awatar
1
lis 25
398
How do I correctly create a calculated field to sum two other field values in Odoo Studio (Odoo Online)? Rozwiązane
development debug
Awatar
Awatar
2
lis 25
434
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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