SlideShare a Scribd company logo
Developing New Widgets for your Views in Owl
Assets Management
How to load templates?
How to write odoo-compatible code?
Owl QWeb
Renderer
Old QWeb Engine
Communication with events
Widget
In Widgets:
● 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
From imperative
to declarative
Widgets are instantiated/updated
manually
Components are instantiated/updated by
Owl
Lifecycle remapping
across boundaries
Widgets
on_attach_callback
on_detach_callback
Components
mounted
willUnmount
JS code style
● No static class fields
● No ultra modern ES features
● No inline template
class MyComponent extends Component {
static template = xml`<div>my template</div>`;
static components = { SubComponent };
...
}
class MyComponent extends Component {
...
}
MyComponent.template =
'myModule.MyComponent';
MyComponent.components = {
SubComponent
};
Owl templates
Add a special attribute: owl=”1” for owl components
<t t-name="AddToGoogleSpreadsheetMenu" owl="1">
<li class="o_menu_item o_add_to_spreadsheet" role="menuitem">
<a class="dropdown-item" href="#"
t-on-click.prevent="_onAddToSpreadsheet">
Add to Google Spreadsheet
</a>
</li>
</t>
View widgets in Owl
<field name="payments_widget" widget="payment"/>
Adding owl field widgets in
views
const AbstractField = require('web.AbstractFieldOwl);
class FieldBadge extends AbstractField {
_getClassFromDecoration(decoration) {
return `bg-${decoration.split('-')[1]}-light`;
}
}
FieldBadge.description = _lt("Badge");
FieldBadge.supportedFieldTypes = ['selection',
'many2one', 'char'];
FieldBadge.template = 'web.FieldBadge';
const registry = require('web.field_registry_owl');
registry
.add('badge', FieldBadge);
<field name="state" widget="badge"/>
It works for: form/list/kanban views
➔ Subclass AbstractFieldOwl (exported in
‘web.AbstractFieldOwl’)
➔ Register it in ‘web.field_registry_owl’
➔ Don’t forget to add widget=... in the arch
What you (might) need to know:
AbstractField API
(web.AbstractFieldOwl)
- field
- isEmpty
- ...
Odoo Env (web.env)
- services
- _t
- bus
- ...
Owl components in Odoo
● Component/Component
● Component/Widget
● Widget/Component
3 kinds of boundaries
1. Component/Component
<t t-name="myModule.AddMyComponent"
t-inherit="web.SomeTemplate"
t-inherit-mode="extension"
owl="1">
<xpath expr="//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
Owl Compatibility Helpers
Component inside Widget Widget inside Component
web.OwlCompatibility
Owl Component
ComponentAdapter
Some Widget
SomeWidget +
WidgetAdapterMixin
ComponentWrapper
Owl Component
2. Component inside Widget
➔ Client action (Hello world)
const AbstractAction =
require('web.AbstractAction');
const { actionRegistry } = require('web.core');
const { ComponentWrapper, WidgetAdapterMixin} =
require('web.OwlCompatibility');
const { Component, tags } = owl;
class HelloWorld extends Component {}
HelloWorld.template = tags.xml`<div>Hello
World!</div>`;
const ClientAction =
AbstractAction.extend(WidgetAdapterMixin, {
start() {
const component =
new ComponentWrapper(this, HelloWorld);
return component.mount(
this.el.querySelector('.o_content')
);
},
});
actionRegistry.add('client_action',
ClientAction);
3. Widget inside Component
with ComponentAdapter
const MyWidget = Widget.extend({
start: function () {
this.$el.text('Hello World!');
}
});
class Parent extends Component {
constructor() {
super(...arguments);
this.MyWidget = MyWidget;
}
}
Parent.template = xml`
<div>
<ComponentAdapter
Component="MyWidget"/>
</div>`;
Parent.components = { ComponentAdapter };
Thank You
Ad

More Related Content

What's hot (20)

Important React Hooks
Important React HooksImportant React Hooks
Important React Hooks
Knoldus Inc.
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
Bui Kiet
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
Jennifer Estrada
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
NAVEENSAGGAM1
 
jQuery
jQueryjQuery
jQuery
Vishwa Mohan
 
Express JS
Express JSExpress JS
Express JS
Alok Guha
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
Jussi Pohjolainen
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
WebStackAcademy
 
jQuery
jQueryjQuery
jQuery
Jay Poojara
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
Scott Wlaschin
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Pei-Tang Huang
 
Introduction to Redux
Introduction to ReduxIntroduction to Redux
Introduction to Redux
Ignacio Martín
 
NestJS
NestJSNestJS
NestJS
Wilson Su
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with Mockito
Richard Paul
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
Mohammed Arif
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
WebStackAcademy
 
Spring Boot
Spring BootSpring Boot
Spring Boot
HongSeong Jeon
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
José Paumard
 
Important React Hooks
Important React HooksImportant React Hooks
Important React Hooks
Knoldus Inc.
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
Bui Kiet
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
NAVEENSAGGAM1
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
Jussi Pohjolainen
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
WebStackAcademy
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
Scott Wlaschin
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with Mockito
Richard Paul
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
Mohammed Arif
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
WebStackAcademy
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
José Paumard
 

Similar to Developing New Widgets for your Views in Owl (20)

Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java Developers
Joonas Lehtinen
 
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress
Maurizio Pelizzone
 
Introduction to Vue.js
Introduction to Vue.jsIntroduction to Vue.js
Introduction to Vue.js
Meir Rotstein
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
DA-14
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Omnia Helmi
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
Tudor Barbu
 
Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2
A.K.M. Ahsrafuzzaman
 
Aura Framework Overview
Aura Framework OverviewAura Framework Overview
Aura Framework Overview
rajdeep
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
Oro Inc.
 
Client Actions In Odoo 17 - Odoo 17 Slides
Client Actions In Odoo 17 - Odoo 17 SlidesClient Actions In Odoo 17 - Odoo 17 Slides
Client Actions In Odoo 17 - Odoo 17 Slides
Celine George
 
Frontend training
Frontend trainingFrontend training
Frontend training
Adrian Caetano
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface Components
Ahmad Hamid
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
Christoffer Noring
 
The Naked Bundle - Tryout
The Naked Bundle - TryoutThe Naked Bundle - Tryout
The Naked Bundle - Tryout
Matthias Noback
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
Tudor Barbu
 
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Joke Puts
 
Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
Gordon Bockus
 
Google Polymer Introduction
Google Polymer IntroductionGoogle Polymer Introduction
Google Polymer Introduction
David Price
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java Developers
Joonas Lehtinen
 
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress
Maurizio Pelizzone
 
Introduction to Vue.js
Introduction to Vue.jsIntroduction to Vue.js
Introduction to Vue.js
Meir Rotstein
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
DA-14
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
Tudor Barbu
 
Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2
A.K.M. Ahsrafuzzaman
 
Aura Framework Overview
Aura Framework OverviewAura Framework Overview
Aura Framework Overview
rajdeep
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
Oro Inc.
 
Client Actions In Odoo 17 - Odoo 17 Slides
Client Actions In Odoo 17 - Odoo 17 SlidesClient Actions In Odoo 17 - Odoo 17 Slides
Client Actions In Odoo 17 - Odoo 17 Slides
Celine George
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface Components
Ahmad Hamid
 
The Naked Bundle - Tryout
The Naked Bundle - TryoutThe Naked Bundle - Tryout
The Naked Bundle - Tryout
Matthias Noback
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
Tudor Barbu
 
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Joke Puts
 
Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
Gordon Bockus
 
Google Polymer Introduction
Google Polymer IntroductionGoogle Polymer Introduction
Google Polymer Introduction
David Price
 
Ad

More from Odoo (20)

Timesheet Workshop: The Timesheet App People Love!
Timesheet Workshop: The Timesheet App People Love!Timesheet Workshop: The Timesheet App People Love!
Timesheet Workshop: The Timesheet App People Love!
Odoo
 
Odoo 3D Product View with Google Model-Viewer
Odoo 3D Product View with Google Model-ViewerOdoo 3D Product View with Google Model-Viewer
Odoo 3D Product View with Google Model-Viewer
Odoo
 
Keynote - Vision & Strategy
Keynote - Vision & StrategyKeynote - Vision & Strategy
Keynote - Vision & Strategy
Odoo
 
Opening Keynote - Unveilling Odoo 14
Opening Keynote - Unveilling Odoo 14Opening Keynote - Unveilling Odoo 14
Opening Keynote - Unveilling Odoo 14
Odoo
 
Extending Odoo with a Comprehensive Budgeting and Forecasting Capability
Extending Odoo with a Comprehensive Budgeting and Forecasting CapabilityExtending Odoo with a Comprehensive Budgeting and Forecasting Capability
Extending Odoo with a Comprehensive Budgeting and Forecasting Capability
Odoo
 
Managing Multi-channel Selling with Odoo
Managing Multi-channel Selling with OdooManaging Multi-channel Selling with Odoo
Managing Multi-channel Selling with Odoo
Odoo
 
Product Configurator: Advanced Use Case
Product Configurator: Advanced Use CaseProduct Configurator: Advanced Use Case
Product Configurator: Advanced Use Case
Odoo
 
Accounting Automation: How Much Money We Saved and How?
Accounting Automation: How Much Money We Saved and How?Accounting Automation: How Much Money We Saved and How?
Accounting Automation: How Much Money We Saved and How?
Odoo
 
Rock Your Logistics with Advanced Operations
Rock Your Logistics with Advanced OperationsRock Your Logistics with Advanced Operations
Rock Your Logistics with Advanced Operations
Odoo
 
Transition from a cost to a flow-centric organization
Transition from a cost to a flow-centric organizationTransition from a cost to a flow-centric organization
Transition from a cost to a flow-centric organization
Odoo
 
Synchronization: The Supply Chain Response to Overcome the Crisis
Synchronization: The Supply Chain Response to Overcome the CrisisSynchronization: The Supply Chain Response to Overcome the Crisis
Synchronization: The Supply Chain Response to Overcome the Crisis
Odoo
 
Running a University with Odoo
Running a University with OdooRunning a University with Odoo
Running a University with Odoo
Odoo
 
Down Payments on Purchase Orders in Odoo
Down Payments on Purchase Orders in OdooDown Payments on Purchase Orders in Odoo
Down Payments on Purchase Orders in Odoo
Odoo
 
Odoo Implementation in Phases - Success Story of a Retail Chain 3Sach food
Odoo Implementation in Phases - Success Story of a Retail Chain 3Sach foodOdoo Implementation in Phases - Success Story of a Retail Chain 3Sach food
Odoo Implementation in Phases - Success Story of a Retail Chain 3Sach food
Odoo
 
Migration from Salesforce to Odoo
Migration from Salesforce to OdooMigration from Salesforce to Odoo
Migration from Salesforce to Odoo
Odoo
 
Preventing User Mistakes by Using Machine Learning
Preventing User Mistakes by Using Machine LearningPreventing User Mistakes by Using Machine Learning
Preventing User Mistakes by Using Machine Learning
Odoo
 
Becoming an Odoo Expert: How to Prepare for the Certification
Becoming an Odoo Expert: How to Prepare for the Certification Becoming an Odoo Expert: How to Prepare for the Certification
Becoming an Odoo Expert: How to Prepare for the Certification
Odoo
 
Instant Printing of any Odoo Report or Shipping Label
Instant Printing of any Odoo Report or Shipping LabelInstant Printing of any Odoo Report or Shipping Label
Instant Printing of any Odoo Report or Shipping Label
Odoo
 
How Odoo helped an Organization Grow 3 Fold
How Odoo helped an Organization Grow 3 FoldHow Odoo helped an Organization Grow 3 Fold
How Odoo helped an Organization Grow 3 Fold
Odoo
 
From Shopify to Odoo
From Shopify to OdooFrom Shopify to Odoo
From Shopify to Odoo
Odoo
 
Timesheet Workshop: The Timesheet App People Love!
Timesheet Workshop: The Timesheet App People Love!Timesheet Workshop: The Timesheet App People Love!
Timesheet Workshop: The Timesheet App People Love!
Odoo
 
Odoo 3D Product View with Google Model-Viewer
Odoo 3D Product View with Google Model-ViewerOdoo 3D Product View with Google Model-Viewer
Odoo 3D Product View with Google Model-Viewer
Odoo
 
Keynote - Vision & Strategy
Keynote - Vision & StrategyKeynote - Vision & Strategy
Keynote - Vision & Strategy
Odoo
 
Opening Keynote - Unveilling Odoo 14
Opening Keynote - Unveilling Odoo 14Opening Keynote - Unveilling Odoo 14
Opening Keynote - Unveilling Odoo 14
Odoo
 
Extending Odoo with a Comprehensive Budgeting and Forecasting Capability
Extending Odoo with a Comprehensive Budgeting and Forecasting CapabilityExtending Odoo with a Comprehensive Budgeting and Forecasting Capability
Extending Odoo with a Comprehensive Budgeting and Forecasting Capability
Odoo
 
Managing Multi-channel Selling with Odoo
Managing Multi-channel Selling with OdooManaging Multi-channel Selling with Odoo
Managing Multi-channel Selling with Odoo
Odoo
 
Product Configurator: Advanced Use Case
Product Configurator: Advanced Use CaseProduct Configurator: Advanced Use Case
Product Configurator: Advanced Use Case
Odoo
 
Accounting Automation: How Much Money We Saved and How?
Accounting Automation: How Much Money We Saved and How?Accounting Automation: How Much Money We Saved and How?
Accounting Automation: How Much Money We Saved and How?
Odoo
 
Rock Your Logistics with Advanced Operations
Rock Your Logistics with Advanced OperationsRock Your Logistics with Advanced Operations
Rock Your Logistics with Advanced Operations
Odoo
 
Transition from a cost to a flow-centric organization
Transition from a cost to a flow-centric organizationTransition from a cost to a flow-centric organization
Transition from a cost to a flow-centric organization
Odoo
 
Synchronization: The Supply Chain Response to Overcome the Crisis
Synchronization: The Supply Chain Response to Overcome the CrisisSynchronization: The Supply Chain Response to Overcome the Crisis
Synchronization: The Supply Chain Response to Overcome the Crisis
Odoo
 
Running a University with Odoo
Running a University with OdooRunning a University with Odoo
Running a University with Odoo
Odoo
 
Down Payments on Purchase Orders in Odoo
Down Payments on Purchase Orders in OdooDown Payments on Purchase Orders in Odoo
Down Payments on Purchase Orders in Odoo
Odoo
 
Odoo Implementation in Phases - Success Story of a Retail Chain 3Sach food
Odoo Implementation in Phases - Success Story of a Retail Chain 3Sach foodOdoo Implementation in Phases - Success Story of a Retail Chain 3Sach food
Odoo Implementation in Phases - Success Story of a Retail Chain 3Sach food
Odoo
 
Migration from Salesforce to Odoo
Migration from Salesforce to OdooMigration from Salesforce to Odoo
Migration from Salesforce to Odoo
Odoo
 
Preventing User Mistakes by Using Machine Learning
Preventing User Mistakes by Using Machine LearningPreventing User Mistakes by Using Machine Learning
Preventing User Mistakes by Using Machine Learning
Odoo
 
Becoming an Odoo Expert: How to Prepare for the Certification
Becoming an Odoo Expert: How to Prepare for the Certification Becoming an Odoo Expert: How to Prepare for the Certification
Becoming an Odoo Expert: How to Prepare for the Certification
Odoo
 
Instant Printing of any Odoo Report or Shipping Label
Instant Printing of any Odoo Report or Shipping LabelInstant Printing of any Odoo Report or Shipping Label
Instant Printing of any Odoo Report or Shipping Label
Odoo
 
How Odoo helped an Organization Grow 3 Fold
How Odoo helped an Organization Grow 3 FoldHow Odoo helped an Organization Grow 3 Fold
How Odoo helped an Organization Grow 3 Fold
Odoo
 
From Shopify to Odoo
From Shopify to OdooFrom Shopify to Odoo
From Shopify to Odoo
Odoo
 
Ad

Recently uploaded (20)

Top 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job ApplicationTop 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job Application
Red Tape Busters
 
NewBase 05 May 2025 Energy News issue - 1785 by Khaled Al Awadi_compressed.pdf
NewBase 05 May 2025  Energy News issue - 1785 by Khaled Al Awadi_compressed.pdfNewBase 05 May 2025  Energy News issue - 1785 by Khaled Al Awadi_compressed.pdf
NewBase 05 May 2025 Energy News issue - 1785 by Khaled Al Awadi_compressed.pdf
Khaled Al Awadi
 
Alec Lawler - A Passion For Building Brand Awareness
Alec Lawler - A Passion For Building Brand AwarenessAlec Lawler - A Passion For Building Brand Awareness
Alec Lawler - A Passion For Building Brand Awareness
Alec Lawler
 
intra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.pptintra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.ppt
NTTDATA INTRAMART
 
Region Research (Hiring Trends) Vietnam 2025.pdf
Region Research (Hiring Trends) Vietnam 2025.pdfRegion Research (Hiring Trends) Vietnam 2025.pdf
Region Research (Hiring Trends) Vietnam 2025.pdf
Consultonmic
 
Level Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up SuccessLevel Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up Success
Best Virtual Specialist
 
Smart Home Market Size, Growth and Report (2025-2034)
Smart Home Market Size, Growth and Report (2025-2034)Smart Home Market Size, Growth and Report (2025-2034)
Smart Home Market Size, Growth and Report (2025-2034)
GeorgeButtler
 
Solaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdfSolaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdf
pchambers2
 
Alan Stalcup - The Enterprising CEO
Alan  Stalcup  -  The  Enterprising  CEOAlan  Stalcup  -  The  Enterprising  CEO
Alan Stalcup - The Enterprising CEO
Alan Stalcup
 
Yuriy Chapran: Zero Trust and Beyond: OpenVPN’s Role in Next-Gen Network Secu...
Yuriy Chapran: Zero Trust and Beyond: OpenVPN’s Role in Next-Gen Network Secu...Yuriy Chapran: Zero Trust and Beyond: OpenVPN’s Role in Next-Gen Network Secu...
Yuriy Chapran: Zero Trust and Beyond: OpenVPN’s Role in Next-Gen Network Secu...
Lviv Startup Club
 
Brandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled MusicianBrandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled Musician
Brandon Flatley
 
Petslify Turns Pet Photos into Hug-Worthy Memories
Petslify Turns Pet Photos into Hug-Worthy MemoriesPetslify Turns Pet Photos into Hug-Worthy Memories
Petslify Turns Pet Photos into Hug-Worthy Memories
Petslify
 
From Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The ChhapaiFrom Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The Chhapai
The Chhapai
 
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
AMITKUMARVERMA479091
 
Influence of Career Development on Retention of Employees in Private Univers...
Influence of Career Development on Retention of  Employees in Private Univers...Influence of Career Development on Retention of  Employees in Private Univers...
Influence of Career Development on Retention of Employees in Private Univers...
publication11
 
20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf
yihong30
 
Mexico Office Furniture Market Share, Size, Growth & Trends (2025-2034)
Mexico Office Furniture Market Share, Size, Growth & Trends (2025-2034)Mexico Office Furniture Market Share, Size, Growth & Trends (2025-2034)
Mexico Office Furniture Market Share, Size, Growth & Trends (2025-2034)
janewatson684
 
Affinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing PresentationAffinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing Presentation
omiller199514
 
Treis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IVTreis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IV
aparicioregina7
 
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOTINTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
CA Suvidha Chaplot
 
Top 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job ApplicationTop 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job Application
Red Tape Busters
 
NewBase 05 May 2025 Energy News issue - 1785 by Khaled Al Awadi_compressed.pdf
NewBase 05 May 2025  Energy News issue - 1785 by Khaled Al Awadi_compressed.pdfNewBase 05 May 2025  Energy News issue - 1785 by Khaled Al Awadi_compressed.pdf
NewBase 05 May 2025 Energy News issue - 1785 by Khaled Al Awadi_compressed.pdf
Khaled Al Awadi
 
Alec Lawler - A Passion For Building Brand Awareness
Alec Lawler - A Passion For Building Brand AwarenessAlec Lawler - A Passion For Building Brand Awareness
Alec Lawler - A Passion For Building Brand Awareness
Alec Lawler
 
intra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.pptintra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.ppt
NTTDATA INTRAMART
 
Region Research (Hiring Trends) Vietnam 2025.pdf
Region Research (Hiring Trends) Vietnam 2025.pdfRegion Research (Hiring Trends) Vietnam 2025.pdf
Region Research (Hiring Trends) Vietnam 2025.pdf
Consultonmic
 
Level Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up SuccessLevel Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up Success
Best Virtual Specialist
 
Smart Home Market Size, Growth and Report (2025-2034)
Smart Home Market Size, Growth and Report (2025-2034)Smart Home Market Size, Growth and Report (2025-2034)
Smart Home Market Size, Growth and Report (2025-2034)
GeorgeButtler
 
Solaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdfSolaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdf
pchambers2
 
Alan Stalcup - The Enterprising CEO
Alan  Stalcup  -  The  Enterprising  CEOAlan  Stalcup  -  The  Enterprising  CEO
Alan Stalcup - The Enterprising CEO
Alan Stalcup
 
Yuriy Chapran: Zero Trust and Beyond: OpenVPN’s Role in Next-Gen Network Secu...
Yuriy Chapran: Zero Trust and Beyond: OpenVPN’s Role in Next-Gen Network Secu...Yuriy Chapran: Zero Trust and Beyond: OpenVPN’s Role in Next-Gen Network Secu...
Yuriy Chapran: Zero Trust and Beyond: OpenVPN’s Role in Next-Gen Network Secu...
Lviv Startup Club
 
Brandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled MusicianBrandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled Musician
Brandon Flatley
 
Petslify Turns Pet Photos into Hug-Worthy Memories
Petslify Turns Pet Photos into Hug-Worthy MemoriesPetslify Turns Pet Photos into Hug-Worthy Memories
Petslify Turns Pet Photos into Hug-Worthy Memories
Petslify
 
From Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The ChhapaiFrom Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The Chhapai
The Chhapai
 
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
AMITKUMARVERMA479091
 
Influence of Career Development on Retention of Employees in Private Univers...
Influence of Career Development on Retention of  Employees in Private Univers...Influence of Career Development on Retention of  Employees in Private Univers...
Influence of Career Development on Retention of Employees in Private Univers...
publication11
 
20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf
yihong30
 
Mexico Office Furniture Market Share, Size, Growth & Trends (2025-2034)
Mexico Office Furniture Market Share, Size, Growth & Trends (2025-2034)Mexico Office Furniture Market Share, Size, Growth & Trends (2025-2034)
Mexico Office Furniture Market Share, Size, Growth & Trends (2025-2034)
janewatson684
 
Affinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing PresentationAffinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing Presentation
omiller199514
 
Treis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IVTreis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IV
aparicioregina7
 
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOTINTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
CA Suvidha Chaplot
 

Developing New Widgets for your Views in Owl

  • 2. Assets Management How to load templates? How to write odoo-compatible code? Owl QWeb Renderer Old QWeb Engine
  • 3. Communication with events Widget In Widgets: ● 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
  • 4. From imperative to declarative Widgets are instantiated/updated manually Components are instantiated/updated by Owl
  • 6. JS code style ● No static class fields ● No ultra modern ES features ● No inline template class MyComponent extends Component { static template = xml`<div>my template</div>`; static components = { SubComponent }; ... } class MyComponent extends Component { ... } MyComponent.template = 'myModule.MyComponent'; MyComponent.components = { SubComponent };
  • 7. Owl templates Add a special attribute: owl=”1” for owl components <t t-name="AddToGoogleSpreadsheetMenu" owl="1"> <li class="o_menu_item o_add_to_spreadsheet" role="menuitem"> <a class="dropdown-item" href="#" t-on-click.prevent="_onAddToSpreadsheet"> Add to Google Spreadsheet </a> </li> </t>
  • 8. View widgets in Owl <field name="payments_widget" widget="payment"/>
  • 9. Adding owl field widgets in views const AbstractField = require('web.AbstractFieldOwl); class FieldBadge extends AbstractField { _getClassFromDecoration(decoration) { return `bg-${decoration.split('-')[1]}-light`; } } FieldBadge.description = _lt("Badge"); FieldBadge.supportedFieldTypes = ['selection', 'many2one', 'char']; FieldBadge.template = 'web.FieldBadge'; const registry = require('web.field_registry_owl'); registry .add('badge', FieldBadge); <field name="state" widget="badge"/> It works for: form/list/kanban views ➔ Subclass AbstractFieldOwl (exported in ‘web.AbstractFieldOwl’) ➔ Register it in ‘web.field_registry_owl’ ➔ Don’t forget to add widget=... in the arch
  • 10. What you (might) need to know: AbstractField API (web.AbstractFieldOwl) - field - isEmpty - ... Odoo Env (web.env) - services - _t - bus - ...
  • 11. Owl components in Odoo ● Component/Component ● Component/Widget ● Widget/Component 3 kinds of boundaries
  • 12. 1. Component/Component <t t-name="myModule.AddMyComponent" t-inherit="web.SomeTemplate" t-inherit-mode="extension" owl="1"> <xpath expr="//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
  • 13. Owl Compatibility Helpers Component inside Widget Widget inside Component web.OwlCompatibility Owl Component ComponentAdapter Some Widget SomeWidget + WidgetAdapterMixin ComponentWrapper Owl Component
  • 14. 2. Component inside Widget ➔ Client action (Hello world) const AbstractAction = require('web.AbstractAction'); const { actionRegistry } = require('web.core'); const { ComponentWrapper, WidgetAdapterMixin} = require('web.OwlCompatibility'); const { Component, tags } = owl; class HelloWorld extends Component {} HelloWorld.template = tags.xml`<div>Hello World!</div>`; const ClientAction = AbstractAction.extend(WidgetAdapterMixin, { start() { const component = new ComponentWrapper(this, HelloWorld); return component.mount( this.el.querySelector('.o_content') ); }, }); actionRegistry.add('client_action', ClientAction);
  • 15. 3. Widget inside Component with ComponentAdapter const MyWidget = Widget.extend({ start: function () { this.$el.text('Hello World!'); } }); class Parent extends Component { constructor() { super(...arguments); this.MyWidget = MyWidget; } } Parent.template = xml` <div> <ComponentAdapter Component="MyWidget"/> </div>`; Parent.components = { ComponentAdapter };

Editor's Notes

  • #7: let’s talk about the odoo ecosystem in general