Skip to content

OWL components ​

Create an OWL component, field widget, public component or service in the current module. The extension adds the files to the manifest assets for you and writes a working example in each.

What you can do ​

ComponentCreated inBundle
Common Componentstatic/src/components/<name>/ (.js, .xml, .css)web.assets_backend
Field Widget Componentstatic/src/views/fields/<name>/ (.js, .xml, .scss)web.assets_backend
Public Componentstatic/src/components/<name>/ (.js, .xml, .scss), registered in public_componentsweb.assets_frontend on Odoo 20, web.assets_backend on 18 and 19
Owl Servicestatic/src/services/<name>/<name>.jsweb.assets_backend

Odoo 20 components use OWL 3. Odoo 18 and 19 use OWL 2, with the /** @odoo-module **/ header and useState. The extension also adds base to the manifest depends if it is missing.

Get started ​

  1. Right-click a folder in your module in the Explorer.
  2. Select Assista Odoo > Create OWL Components, then choose the component type.
  3. Enter a component name and press Enter.

The command works only inside an Odoo module. If a folder with the component's name already exists, the extension shows an error and creates nothing.

How names are formed ​

The extension removes every character that is not a letter, _ or a space. It turns spaces into _ and lowercases the result to get the folder and file name. The class name is that name in CamelCase.

You enterFolder and filesClass
My Widgetmy_widgetMyWidget
MyWidgetmywidgetMywidget

Digits are dropped, so Chart2 becomes chart. Separate words with spaces or underscores to get a CamelCase class name.

What each type contains ​

Common Component ​

A reusable component with a counter, a text input and a loading state. Use it in another component's template, after you add it to that component's static components.

xml
<MyWidget title="'Hello'"/>

The template is named <module>.<ClassName>, and the class sits in static/src/components/my_widget/my_widget.js.

Field Widget Component ​

A widget for Char fields. It shows the value in read-only mode and an input in edit mode. It is registered in the fields registry under the folder name. Use it in a view with widget:

xml
<field name="name" widget="my_widget"/>

Change supportedTypes in the generated file to use it on other field types.

Public Component ​

A website and portal component that has a child component showing a labelled value. It is registered in the public_components registry. On Odoo 20, the registry key is <module>.<ClassName>, and you place it in a QWeb page with:

xml
<owl-component name="my_module.MyWidget" t-att-props="json.dumps({'title': 'Hello'})"/>

On Odoo 18 and 19, the key is the component's folder name.

Owl Service ​

A service that depends on orm, keeps a private counter and exposes a small API. It is registered in the services registry under the folder name. Use it in a component:

js
this.myService = useService("my_service");

Tips and limits ​

  • Field widgets and public components appear in smart suggestions and Go to Definition once the index includes them.
  • Check the Odoo version in the status bar first. The generated JavaScript differs between OWL 2 and OWL 3.
  • To scaffold a whole module around an OWL client action, see Module templates.

Next steps ​

Built by Cybrosys Technologies.