Odoo 18 introduces powerful new frontend capabilities with OWL (Odoo Web Library) – a modern reactive JavaScript framework inspired by React and Vue.js. In this tutorial, we’ll walk through creating a new custom view using OWL in Odoo 18.
📌 Prerequisites
Before we begin, make sure you have:
- Odoo 18 running in developer mode
- Basic knowledge of JavaScript and Python
- Familiarity with XML QWeb templates and the Odoo module structure
🚀 Step 1: Create a Custom Module
Start by generating a new module, e.g., my_custom_view
.
|
|
Inside your module, create the basic structure for models, views, and static assets.
📁 Step 2: Define the Python Model
In models/my_model.py
:
|
|
Don’t forget to load the model in __init__.py
and add it to __manifest__.py
.
🖼️ Step 3: Create OWL Component
In static/src/js/components/MyCustomView.js
:
|
|
And in static/src/xml/my_template.xml
:
|
|
⚙️ Step 4: Register the View in the Client Action
In static/src/js/my_custom_view.js
:
|
|
🧩 Step 5: Add Action and Menu in XML
In views/my_custom_view.xml
:
|
|
🧪 Step 6: Test It!
-
Upgrade the module:
1
odoo-bin -u my_custom_view -d your_db_name
-
Navigate to your new menu item and see your custom OWL view in action.
🧠 Conclusion
Odoo 18’s adoption of OWL gives frontend developers a clean and modern way to build UI components. With just a few files, you can create interactive, reactive views that feel native in the Odoo web client.
Want more OWL tutorials? Stay tuned for part 2 where we add state management and RPC calls!