The document discusses integrating Odoo widgets and Owl components. It provides information on:
1. How to add Owl components to Odoo templates using XPath and registering components.
2. The three kinds of boundaries between Owl components and Odoo widgets - component to component, component to widget, and widget to component. It describes helpers for each case.
3. How to create a new field widget by subclassing AbstractFieldOwl and registering it in the field registry.
4. Notes on the Odoo environment and component lifecycle when integrating Owl and Odoo.
Assets Management
How toload templates?
How to write odoo-compatible code?
Owl QWeb
Renderer
Old QWeb Engine
3.
Communication with events
Widget
InWidgets:
● events bubble up widget tree
● generated with trigger_up
● caught with custom_events
● use underscores: “something_happened”
In Components:
● events bubble up DOM tree
● generated with trigger
● caught with t-on- directive
● use dash: “something-happened”
across boundaries
Component
Widget
1. Component/Component
<t t-name="myModule.AddMyComponent"
t-inherit="web.SomeTemplate"
t-inherit-mode="extension"
owl="1">
<xpathexpr="//div[@class='abc']"
position="inside">
<MyComponent mode="’readonly’" />
</xpath>
</t>
class MyComponent extends Component {
...
}
// register the new component as a sub component for
the parent
ParentComponent.components.MyComponent = MyComponent
Standard owl development.
➔ XPath the parent template to add a tag
<MyComponent/> where needed (it
works!!!)
➔ Add MyComponent to parent static
components key