Professional Documents
Culture Documents
Hooks in Odoo OWL Framework
Hooks in Odoo OWL Framework
Hooks in Odoo OWL Framework
By:Mashood K
AUG 5,2020
The owl is a framework from Odoo to meet Odoo’s front end requirements. We have talked about it in
the previous section about Odoo OWL Framework. Today, we are going to take a look at what are
hooks in the OWL framework and how do we use it.
Hooks are used to reusing stateful logic between components. Hooks are always observed with the
Observer class to keep track of what is going on in states and react to their changes.
1. useState Hook
2. onMounted
3. onWillUnMount
4. onWillPatch
5. onPatched
6. onWillStart
Home Odoo Implementation Customization Training Support Resources B
7. onWillUpdateProps
https://www.cybrosys.com/blog/hooks-in-odoo-owl-framework 1/9
17/06/2021 Hooks in Odoo OWL Framework
1. useState Hook
useState is one of the most important and common hooks in the owl framework. It has a major role in
the feature ‘reactive framework’. This hook helps to render a view when a state of a component is
changed. This makes the Owl framework ‘reactive’ as it always listens to the changes occurring in the
states of a component.
As you can see above, when the value of the state is changed from the function increment(), it
renders the template again with the help of useState. We don't want to re-render the template again
and again whenever the value of a state is changed. You can see that the state is defined as its value
using useState as an object. That is because UseState only accepts a value as an array or object.
Since it is the only possible way to react to a state change.
2. onMounted
onMounted hooks register a callback that is called when the owl component is mounted from the
virtual DOM to the UI representation(Simply component mounting). In other words, onMounted hook
calls when a component is represented in the view.
3.onWillUnMount
onMounted hooks register a callback that is called when the owl component is unmounted from the
view.
4.onWillPatch
onMounted hooks register a callback that is called before the component is patched.
5.onPatched
onMounted hooks register a callback that is called after the component is patched.
6.onWillStart
This hook will be called just before the component is rendered for the first time. It will be useful if we
need to do some actions before the component is rendered to the view like loading some initial data.
Home Odoo Implementation Customization Training Support Resources B
7.onWillUpdateProps
https://www.cybrosys.com/blog/hooks-in-odoo-owl-framework 2/9
17/06/2021 Hooks in Odoo OWL Framework
This is also an asynchronous hook which is called whenever an update is made to a related
component. The reactive nature of the OWL framework can be maintained using this amazing hook.
Watch our Odoo OWL Framework webinar to know more about Hooks in Odoo OWL
If you need any assistance in odoo, we are online, please chat with us.
« Previous
Next »
Related Blogs
Prerequisites On Monthly Payroll Management With Odoo
Home Odoo Implementation Customization Training Support Resources B
Prerequisites On Monthly Payroll Management With Odoo
Odoo Dignified Tools Will Help Your Company Stand Above The Curve In Productivity
https://www.cybrosys.com/blog/hooks-in-odoo-owl-framework 3/9
17/06/2021 Hooks in Odoo OWL Framework
Odoo Dignified Tools Will Help Your Company Stand Above The Curve In Productivity
0
Comments
Leave a comment
Name
Email
Website
Comment
Post Comment
https://www.cybrosys.com/blog/hooks-in-odoo-owl-framework 4/9
17/06/2021 Hooks in Odoo OWL Framework
Recent Posts
Odoo Dignified Tools Will Help Your Company Stand Above The Curve In Productivity
https://www.cybrosys.com/blog/hooks-in-odoo-owl-framework 5/9
17/06/2021 Hooks in Odoo OWL Framework
CALICUT
Cybrosys Technologies Pvt. Ltd.
Kakkancherry, Calicut
Kerala, India - 673635 Home Odoo Implementation Customization Training Support Resources B
https://www.cybrosys.com/blog/hooks-in-odoo-owl-framework 6/9
17/06/2021 Hooks in Odoo OWL Framework
LONDON
Cybrosys Limited
Alpha House,
KOCHI
Cybrosys Technologies Pvt. Ltd.
Infopark, Kakkanad,
BANGALORE
Cybrosys Techno Solutions
Dickenson Road,
https://www.cybrosys.com/blog/hooks-in-odoo-owl-framework 7/9
17/06/2021 Hooks in Odoo OWL Framework
Full Name
Phone
Your Message
SEND
QUICK LINKS
Odoo
Odoo Apps
Odoo Partners
Contact us
Sitemap
SERVICES
Odoo Customization
Odoo Implementation
Odoo Integration
Odoo Support
Odoo Migration
Odoo Training
Odoo Licensing
https://www.cybrosys.com/blog/hooks-in-odoo-owl-framework 8/9
17/06/2021 Hooks in Odoo OWL Framework
REFERENCE
Odoo ERP
Odoo Software
Odoo vs SAP
Odoo vs Dynamics
Odoo vs ERP Next
Odoo vs Netsuite
Odoo vs Sage
STAY IN TOUCH
+91 8606827707
info@cybrosys.com
+91 8606827707
CONNECT SOCIALLY
Rights
Reserved. Privacy Policy
https://www.cybrosys.com/blog/hooks-in-odoo-owl-framework 9/9