<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amrithesh on Medium]]></title>
        <description><![CDATA[Stories by Amrithesh on Medium]]></description>
        <link>https://medium.com/@amritheshvenugopalan?source=rss-0f9ec65df57d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ma7-6oN5PEo3x67wmS9pIw.jpeg</url>
            <title>Stories by Amrithesh on Medium</title>
            <link>https://medium.com/@amritheshvenugopalan?source=rss-0f9ec65df57d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 03:57:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amritheshvenugopalan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Basics of Owl Js — Templates and Directives]]></title>
            <link>https://medium.com/@amritheshvenugopalan/basics-of-owl-js-templates-and-directives-2291d7d2c3c2?source=rss-0f9ec65df57d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2291d7d2c3c2</guid>
            <category><![CDATA[template]]></category>
            <category><![CDATA[erp-software]]></category>
            <category><![CDATA[owl-j]]></category>
            <category><![CDATA[xml]]></category>
            <category><![CDATA[odoo]]></category>
            <dc:creator><![CDATA[Amrithesh]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 02:06:45 GMT</pubDate>
            <atom:updated>2026-03-12T02:06:45.905Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JvJALgnr4Y_h2KOhAkFfIA.png" /></figure><h3>1. Defining and Rendering Templates</h3><h3>t-name</h3><p>The t-name directive defines a <strong>unique identifier for a template</strong>. This name is later referenced from the OWL component.</p><pre>&lt;templates xml:space=&quot;preserve&quot;&gt;<br>    &lt;t t-name=&quot;owl_counter.CounterScreen&quot;&gt;<br>        &lt;div&gt;<br>            &lt;h3&gt;Counter Screen&lt;/h3&gt;<br>        &lt;/div&gt;<br>    &lt;/t&gt;<br>&lt;/templates&gt;</pre><h3>How it works</h3><p>The OWL component references this template:</p><pre>export class CounterScreen extends Component {}<br>CounterScreen.template = &quot;owl_counter.CounterScreen&quot;;</pre><p>The template is then rendered as the UI of the component.</p><h3>t-call</h3><p>t-call is used to <strong>render another template inside the current template</strong>. This helps reuse common UI elements.</p><pre>&lt;t t-name=&quot;owl_counter.MainTemplate&quot;&gt;<br>    &lt;div&gt;<br>        &lt;h3&gt;Main Screen&lt;/h3&gt;<br>        &lt;t t-call=&quot;owl_counter.SubTemplate&quot;/&gt;<br>    &lt;/div&gt;<br>&lt;/t&gt;<br>&lt;t t-name=&quot;owl_counter.SubTemplate&quot;&gt;<br>    &lt;p&gt;This content comes from another template.&lt;/p&gt;<br>&lt;/t&gt;</pre><h3>When to use it</h3><ul><li>Reusing UI blocks</li><li>Creating layout templates</li><li>Sharing small UI fragments</li></ul><h3>2. Output and Data Binding</h3><h3>t-esc</h3><p>t-esc is used to <strong>display dynamic values in the template</strong>.</p><pre>&lt;p&gt;Total Partners: &lt;t t-esc=&quot;state.partnerCount&quot;/&gt;&lt;/p&gt;</pre><p>If state.partnerCount equals 10, the rendered output will be:</p><pre>Total Partners: 10</pre><h3>Using Props</h3><pre>&lt;p&gt;&lt;t t-esc=&quot;props.message || &#39;Loading...&#39;&quot;/&gt;&lt;/p&gt;</pre><p>This prints the message prop if available, otherwise shows <strong>Loading...</strong></p><h3>t-out</h3><p>t-out works similarly to t-esc, but <strong>does not escape HTML</strong>.</p><pre>&lt;div t-out=&quot;state.htmlContent&quot;/&gt;</pre><h3>3. Form Binding</h3><h3>t-model</h3><p>t-model provides <strong>two-way data binding</strong> between form inputs and component state.</p><p>When the user changes the input value, the state updates automatically.</p><pre>&lt;input<br>    type=&quot;text&quot;<br>    placeholder=&quot;Search partner...&quot;<br>    t-model=&quot;state.partnerSearch&quot;<br>/&gt;</pre><pre>setup() {<br>    this.state = useState({<br>        partnerSearch: &quot;&quot;,<br>    });<br>}</pre><p>Whenever the user types in the input field, state.partnerSearch updates automatically.</p><h3>Numeric Input</h3><p>OWL also supports typed binding.</p><pre>&lt;input t-model.number=&quot;state.quantity&quot;/&gt;</pre><p>This ensures the value is parsed as a <strong>number instead of a string</strong>.</p><h3>4. Conditional Rendering</h3><h3>t-if, t-elif, and t-else</h3><p>These directives allow templates to <strong>render elements conditionally</strong>.</p><h3>Example</h3><pre>&lt;div t-if=&quot;state.partners.length &gt; 0&quot;&gt;<br>    &lt;p&gt;Partners found!&lt;/p&gt;<br>&lt;/div&gt;<br>&lt;div t-elif=&quot;state.isSearching&quot;&gt;<br>    &lt;p&gt;Searching partners...&lt;/p&gt;<br>&lt;/div&gt;<br>&lt;div t-else=&quot;&quot;&gt;<br>    &lt;p&gt;No partners found.&lt;/p&gt;<br>&lt;/div&gt;</pre><h3>Behavior</h3><p>ConditionResultpartners existShows “Partners found!”searchingShows “Searching partners…”otherwiseShows “No partners found”</p><p>Elements that fail the condition are <strong>not rendered in the DOM</strong>.</p><h3>5. Loops and Iteration</h3><h3>t-foreach, t-as, and t-key</h3><p>These directives allow templates to <strong>iterate over arrays or objects</strong>.</p><pre>&lt;tbody t-foreach=&quot;props.partners&quot; t-as=&quot;partner&quot; t-key=&quot;partner.id&quot;&gt;<br>    &lt;tr&gt;<br>        &lt;td&gt;&lt;t t-esc=&quot;partner.name&quot;/&gt;&lt;/td&gt;<br>        &lt;td&gt;&lt;t t-esc=&quot;partner.email&quot;/&gt;&lt;/td&gt;<br>    &lt;/tr&gt;<br>&lt;/tbody&gt;</pre><h3>Explanation</h3><p>DirectivePurposet-foreachList to iteratet-asVariable for each itemt-keyUnique identifier</p><h3>Why t-key is Important</h3><p>OWL uses a <strong>virtual DOM</strong>.<br> t-key helps OWL track elements efficiently during updates.</p><p>Missing t-key can cause <strong>unexpected rendering behavior</strong>.</p><h3>6. Dynamic Attributes</h3><h3>t-att</h3><p>t-att dynamically assigns values to HTML attributes.</p><h3>Example</h3><pre>&lt;input type=&quot;text&quot; t-att-value=&quot;props.partner.email&quot;/&gt;</pre><p>This dynamically sets the input value to the partner’s email.</p><h3>t-attf</h3><p>t-attf allows <strong>string interpolation with dynamic values</strong>.</p><h3>Example</h3><pre>&lt;input<br>    type=&quot;text&quot;<br>    t-attf-value=&quot;Partner: {{props.partner.name}}&quot;<br>/&gt;</pre><p>If the partner name is <strong>John</strong>, the rendered value becomes:</p><h3>7. DOM References</h3><h3>t-ref</h3><p>t-ref allows the component to <strong>directly reference a DOM element</strong>.</p><p>This works together with the <strong>useRef hook</strong> in JavaScript.</p><h3>Example XML</h3><pre>&lt;input<br>    type=&quot;text&quot;<br>    placeholder=&quot;Search partner&quot;<br>    t-ref=&quot;searchPartner&quot;<br>/&gt;</pre><h3>JavaScript</h3><pre>import { useRef, onMounted } from &quot;@odoo/owl&quot;;<br>setup() {<br>    this.searchPartner = useRef(&quot;searchPartner&quot;);<br>    onMounted(() =&gt; {<br>        this.searchPartner.el.focus();<br>    });<br>}</pre><p>The input field automatically receives focus after the component mounts.</p><h3>8. Modifying Existing Templates Using Inheritance</h3><p>One of Odoo’s powerful features is the ability to <strong>extend or modify existing templates without editing the original code</strong>.</p><p>This is done using <strong>template inheritance and XPath expressions</strong>.</p><h3>t-inherit</h3><p>t-inherit specifies the template that we want to extend.</p><h3>t-inherit-mode</h3><p>The t-inherit-mode attribute defines <strong>how the inheritance should behave</strong>. OWL supports two main modes:</p><ul><li>extension</li><li>primary</li></ul><p>t-inherit-mode=&quot;extension&quot; This is the <strong>most commonly used mode</strong>. It allows you to modify an existing template by inserting, replacing, or altering elements using XPath.The original template remains intact, and your changes are applied on top of it.</p><pre>&lt;t t-inherit=&quot;web.SomeTemplate&quot; t-inherit-mode=&quot;extension&quot;&gt;<br><br>    &lt;xpath expr=&quot;//button[@name=&#39;cancel&#39;]&quot; position=&quot;after&quot;&gt;<br>        &lt;button class=&quot;btn btn-primary&quot;&gt;<br>            Print Report<br>        &lt;/button&gt;<br>    &lt;/xpath&gt;<br><br>&lt;/t&gt;</pre><p>t-inherit-mode=&quot;primary&quot; is used when you want to create a new template that inherits the structure of another template but becomes its own independent template.</p><p>In this case:</p><ul><li>The parent template acts as a <strong>base template</strong></li><li>The new template gets its <strong>own name</strong></li><li>It can then be used directly by OWL components</li></ul><pre>&lt;t t-name=&quot;custom_module.CustomTemplate&quot;<br>   t-inherit=&quot;web.SomeTemplate&quot;<br>   t-inherit-mode=&quot;primary&quot;&gt;<br><br>    &lt;xpath expr=&quot;//div[@class=&#39;o_content&#39;]&quot; position=&quot;inside&quot;&gt;<br>        &lt;p&gt;Custom content added in inherited template&lt;/p&gt;<br>    &lt;/xpath&gt;<br><br>&lt;/t&gt;</pre><h3>XPath Expressions</h3><p>Inside the inherited template, XPath is used to target specific elements.</p><pre>&lt;xpath expr=&quot;//button[@name=&#39;cancel&#39;]&quot; position=&quot;after&quot;&gt;<br>    &lt;button class=&quot;btn btn-primary&quot;&gt;<br>        Print Report<br>    &lt;/button&gt;<br>&lt;/xpath&gt;</pre><p>This adds a <strong>new button after the cancel button</strong>.</p><h3>XPath Positions</h3><ul><li>inside → Adds content inside the element</li><li>before → Inserts before the element</li><li>after → Inserts after the element</li><li>attributes → Replaces the element attributes</li></ul><pre>&lt;xpath expr=&quot;//div[@class=&#39;card&#39;]&quot; position=&quot;attributes&quot;&gt;<br>    &lt;attribute name=&quot;class&quot;&gt;hello world&lt;/attribute&gt;<br>&lt;/xpath&gt;</pre><p>This adds a new CSS class to the existing element.</p><h3>Conclusion</h3><p>QWeb templates are a core part of OWL component development in Odoo. They allow developers to combine <strong>HTML structure with dynamic behavior</strong> using powerful directives.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2291d7d2c3c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Owl Js : Environment and Component Communication]]></title>
            <link>https://medium.com/@amritheshvenugopalan/basics-of-owl-js-environment-and-component-communication-385580e60926?source=rss-0f9ec65df57d------2</link>
            <guid isPermaLink="false">https://medium.com/p/385580e60926</guid>
            <category><![CDATA[owl-j]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[erp-software]]></category>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Amrithesh]]></dc:creator>
            <pubDate>Tue, 10 Mar 2026 01:44:42 GMT</pubDate>
            <atom:updated>2026-03-10T01:44:42.831Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NbaR1gRez0O9I-AuRZHOFA.png" /></figure><h3>1. Parent to Child Communication Using Props</h3><p>The most common way to communicate between components is through <strong>Props (Properties)</strong>.</p><p>Props allow a parent component to pass <strong>data or functions</strong> to a child component through the XML template.</p><h3>Passing Data via Props</h3><p>Suppose a parent component contains a list of partners and wants to render a child component for each partner.</p><h3>Parent Template</h3><pre>&lt;tbody t-foreach=&quot;state.partners&quot; t-as=&quot;partner&quot; t-key=&quot;partner.id&quot;&gt;<br>    &lt;CounterPartner partner=&quot;partner&quot;/&gt;<br>&lt;/tbody&gt;</pre><p>Here:</p><ul><li>state.partners is the array</li><li>Each partner object is passed to the CounterPartner component</li></ul><h3>Child Component</h3><pre>export class CounterPartner extends Component {<br>    static props = {<br>        partner: { type: Object },<br>    };<br>}</pre><p>The child component now has access to the partner via:</p><pre>this.props.partner</pre><h3>Passing Functions via Props</h3><p>In many cases, the parent component contains the <strong>main logic</strong>, while the child only triggers actions.</p><p>A function from the parent can be passed down using .bind.</p><h3>Parent Template</h3><pre>&lt;CounterPartner<br>    partner=&quot;partner&quot;<br>    onDelete.bind=&quot;onDeletePartner&quot;<br>/&gt;</pre><p>The .bind ensures the <strong>correct </strong><strong>this context</strong> is preserved.</p><h3>Parent Component</h3><pre>onDeletePartner(partnerId) {<br>    console.log(&quot;Deleting partner:&quot;, partnerId);<br>}</pre><h3>Child Component</h3><pre>export class CounterPartner extends Component {<br>    static props = {<br>        partner: { type: Object },<br>        onDelete: { type: Function },<br>    };<br>    deletePartner() {<br>        this.props.onDelete(this.props.partner.id);<br>    }<br>}</pre><h3>Child Template</h3><pre>&lt;button t-on-click=&quot;deletePartner&quot;&gt;<br>    Delete<br>&lt;/button&gt;</pre><p>When the button is clicked, the child calls the <strong>parent’s function</strong>.</p><h3>2. Child to Parent Communication Using Custom Events</h3><p>Instead of passing functions through props, a child component can <strong>emit custom events</strong> that the parent listens for.</p><p>This approach keeps components <strong>loosely coupled</strong>.</p><h3>Dispatching a Custom Event</h3><p>The child component dispatches a DOM event.</p><h3>Child Component</h3><pre>onInput(ev) {<br>    this.searchPartner.el.dispatchEvent(<br>        new CustomEvent(&quot;custom-event&quot;, {<br>            bubbles: true,<br>            detail: {<br>                value: ev.target.value,<br>            },<br>        })<br>    );<br>}</pre><p>Key parts:</p><p>PropertyPurposebubbles: trueAllows event to propagate updetailData sent to the parent</p><h3>Listening to the Event in the Parent</h3><h3>Parent Template</h3><pre>&lt;CounterSearch t-on-custom-event=&quot;onSearchChanged&quot;/&gt;</pre><p>custom-event becomes:</p><pre>t-on-custom-event</pre><h3>Parent Component</h3><pre>onSearchChanged(ev) {<br>    const value = ev.detail.value;<br>    console.log(&quot;Search value:&quot;, value);<br>}</pre><p>This allows the parent to <strong>react to child interactions</strong> without directly coupling logic.</p><h3>3. Using Environments for Global Component Communication</h3><p>When component trees become deeper, passing props through multiple layers becomes tedious.</p><p>Example structure:</p><pre>Parent<br> └── Child<br>      └── Grandchild<br>           └── GreatGrandchild</pre><p>Passing props through every layer is known as <strong>prop drilling</strong>.</p><p>OWL solves this problem using <strong>Environments (</strong><strong>env)</strong>.</p><p>The environment is a shared object that is available to <strong>all descendant components</strong>.</p><h3>4. Creating a Sub Environment with useSubEnv</h3><p>A parent component can inject data or functions into the environment.</p><h3>Parent Component</h3><pre>import { useSubEnv } from &quot;@odoo/owl&quot;;<br><br>export class Counter extends Component {<br>    setup() {<br>        this.state = useState({<br>            search: &quot;&quot;,<br>        });<br>        useSubEnv({<br>            onSearch: this.onSearch.bind(this),<br>            parentState: this.state,<br>        });<br>    }<br>    onSearch(value) {<br>        this.state.search = value.toLowerCase();<br>    }<br>}</pre><p>This adds two items to the environment:</p><ul><li>onSearch</li><li>parentState</li></ul><p>These are now accessible to all children.</p><h3>5. Accessing the Environment in Child Components</h3><p>Child components can access the environment using <strong>useEnv</strong>.</p><h3>Child Component</h3><pre>import { useEnv } from &quot;@odoo/owl&quot;;<br><br>export class CounterSearch extends Component {<br>    setup() {<br>        this.env = useEnv();<br>    }<br>    onInput(value) {<br>        // Call parent method<br>        this.env.onSearch(value);<br>        // Modify parent state<br>        this.env.parentState.lenPartner = value.length;<br>    }<br>}</pre><p>The child component can now <strong>directly access the parent’s logic and state</strong>.</p><h3>6. useChildSubEnv</h3><p>OWL also provides <strong>useChildSubEnv</strong>.</p><p>The difference:</p><ul><li>useSubEnv → Extends environment for the component and its children</li><li>useChildSubEnv → Extends environment only for child components</li></ul><p>This allows developers to <strong>control environment scope more precisely</strong>.</p><h3>Conclusion</h3><p>Component communication is essential when building scalable OWL applications in Odoo.</p><p>OWL provides multiple ways to handle interactions between components:</p><ul><li><strong>Props</strong> allow direct parent-to-child data transfer</li><li><strong>Custom events</strong> allow children to notify parents of changes</li><li><strong>Environments</strong> allow deeply nested components to share state and logic</li></ul><p>Understanding these patterns helps developers design <strong>clean, modular, and maintainable OWL applications</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=385580e60926" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Owl Js — Services]]></title>
            <link>https://medium.com/@amritheshvenugopalan/basics-of-owl-js-services-dac78f3a92f5?source=rss-0f9ec65df57d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dac78f3a92f5</guid>
            <category><![CDATA[owl-j]]></category>
            <category><![CDATA[odoo-19]]></category>
            <category><![CDATA[erp-software]]></category>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Amrithesh]]></dc:creator>
            <pubDate>Tue, 10 Mar 2026 01:44:19 GMT</pubDate>
            <atom:updated>2026-03-10T01:44:19.982Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mB7Lxk--8wJtaZ7WCWTPQg.png" /></figure><h3>1. What Are Services in Odoo OWL?</h3><p>Services are <strong>shared framework-level utilities</strong> available throughout the Odoo web client.</p><p>They help components interact with:</p><ul><li>the <strong>backend (ORM)</strong></li><li>the <strong>UI system</strong></li><li>the <strong>navigation system</strong></li><li>the <strong>browser environment</strong></li></ul><p>Services are accessed using the <strong>useService hook</strong>.</p><h3>2. Injecting a Service</h3><p>Services must always be injected inside the <strong>setup() method</strong> of an OWL component.</p><pre>/** @odoo-module **/<br><br>import { Component } from &quot;@odoo/owl&quot;;<br>import { useService } from &quot;@web/core/utils/hooks&quot;;<br>export class ExampleComponent extends Component {<br>    setup() {<br>        this.orm = useService(&quot;orm&quot;);<br>        this.notification = useService(&quot;notification&quot;);<br>    }<br>}</pre><p>Once injected, these services can be used anywhere inside the component.</p><h3>3. Data and Communication Services</h3><p>These services are mainly used for <strong>interacting with the backend or external APIs</strong>.</p><h3>ORM Service (orm)</h3><p>The <strong>ORM service</strong> allows OWL components to interact with the Odoo backend using the standard ORM methods.</p><p>Common operations include:</p><ul><li>searchRead</li><li>create</li><li>write</li><li>unlink</li><li>calling custom model methods</li></ul><h3>Example: Fetching Records</h3><pre>this.partners = await this.orm.searchRead(<br>    &quot;res.partner&quot;,<br>    [[&quot;name&quot;, &quot;ilike&quot;, this.state.search]],<br>    [&quot;id&quot;, &quot;name&quot;, &quot;email&quot;],<br>    { limit: 5 }<br>);</pre><h3>Example: Deleting Records</h3><pre>await this.orm.unlink(&quot;res.partner&quot;, [partnerId]);</pre><h3>HTTP Service (http)</h3><p>The <strong>HTTP service</strong> is used when making raw HTTP requests.</p><p>It is typically used for:</p><ul><li>calling custom controllers</li><li>external APIs</li><li>downloading files</li></ul><pre>this.http = useService(&quot;http&quot;);<br>const response = await this.http.get(&quot;/my/custom/route&quot;);</pre><h3>Action Service (action)</h3><p>The <strong>action service</strong> allows OWL components to trigger <strong>Odoo window actions</strong> and navigate between views.</p><h3>Example: Opening a List View Dynamically</h3><pre>this.actionService.doAction({<br>    type: &quot;ir.actions.act_window&quot;,<br>    res_model: &quot;res.partner&quot;,<br>    name: &quot;Partners&quot;,<br>    domain: [[&quot;id&quot;, &quot;in&quot;, partnerIds]],<br>    views: [[false, &quot;list&quot;], [false, &quot;form&quot;]],<br>    target: &quot;current&quot;,<br>});</pre><h3>4. UI and Feedback Services</h3><p>These services help provide <strong>visual feedback to users</strong>.</p><h3>Notification Service (notification)</h3><p>The notification service displays <strong>toast messages</strong> in the top-right corner of the screen.</p><h3>Example</h3><pre>this.notification.add(&quot;Saved successfully!&quot;, {<br>    title: _t(&quot;Successful&quot;),<br>    type: &quot;success&quot;,<br>});</pre><h3>Notification Types</h3><ul><li>success → Successful operation</li><li>info → Informational message</li><li>warning → Warning message</li><li>danger → Error message</li></ul><h3>Dialog Service (dialog)</h3><p>The dialog service is used to open <strong>modal dialogs</strong>.</p><p>A common example is a <strong>confirmation dialog</strong>.</p><h3>Example</h3><pre>import { ConfirmationDialog } from &quot;@web/core/confirmation_dialog/confirmation_dialog&quot;;<br></pre><pre>this.dialog.add(ConfirmationDialog, {<br>    title: &quot;Are you sure?&quot;,<br>    body: &quot;This will delete the record.&quot;,<br>    confirm: () =&gt; {<br>        console.log(&quot;Confirmed&quot;);<br>    },<br>    cancel: () =&gt; {<br>        console.log(&quot;Cancelled&quot;);<br>    },<br>});</pre><h3>Overlay Service (overlay)</h3><p>The overlay service allows you to <strong>block the screen with a loading overlay</strong>.</p><p>It is useful when performing long-running operations.</p><h3>Example</h3><pre>const removeOverlay = this.overlay.add(<br>    LoadingOverlay,<br>    { message: &quot;Processing...&quot; }<br>);<br></pre><pre>removeOverlay();</pre><h3>Popover Service (popover)</h3><p>Popovers display small contextual UI elements attached to a specific DOM element.</p><h3>Example</h3><pre>this.closePopover = this.popover.add(<br>    ev.target,<br>    PartnerPopover,<br>    { partner: partner }<br>);</pre><p>This creates a popover attached to the clicked element.</p><h3>Tooltip Service (tooltip)</h3><p>The tooltip service adds <strong>hover tooltips</strong> to elements.</p><h3>Example</h3><pre>this.tooltip.add(this.searchInput.el, {<br>    tooltip: &quot;Search partner&quot;,<br>    position: &quot;top&quot;,<br>});</pre><h3>Effect Service (effect)</h3><p>The effect service triggers <strong>visual animations</strong> in the Odoo UI.</p><p>One famous example is the <strong>Rainbow Man animation</strong>.</p><h3>Example</h3><pre>this.effect.add({<br>    type: &quot;rainbow_man&quot;,<br>    message: &quot;Record saved successfully!&quot;,<br>});</pre><h3>5. Keyboard and Utility Services</h3><p>These services improve <strong>user interaction and productivity</strong>.</p><h3>Hotkey Service (hotkey)</h3><p>The hotkey service allows developers to bind keyboard shortcuts.</p><h3>Example</h3><pre>this.hotkey = useService(&quot;hotkey&quot;);</pre><pre>this.hotkey.add(&quot;control+s&quot;, () =&gt; {<br>    console.log(&quot;Save shortcut triggered&quot;);<br>});</pre><p>This triggers the function when the user presses <strong>Ctrl + S</strong>.</p><h3>Command Service (command)</h3><p>The command service allows you to register commands in <strong>Odoo’s Command Palette</strong>.</p><p>The command palette is opened using:</p><ul><li><strong>CTRL + K</strong></li><li><strong>CMD + K</strong></li></ul><h3>Example</h3><pre>this.command = useService(&quot;command&quot;);</pre><pre>this.command.add(&quot;Create New Partner&quot;, () =&gt; {<br>    this.actionService.doAction(&quot;base.action_partner_form&quot;);<br>});</pre><p>This allows users to open the partner form using the command palette.</p><h3>UI Service (ui)</h3><p>The UI service provides general control over the web client interface.</p><p>It can be used to <strong>block or unblock the UI</strong>.</p><h3>Example</h3><pre>this.ui.block();</pre><pre>// perform operation<br>this.ui.unblock();</pre><p>This prevents user interaction while an operation is running.</p><h3>Conclusion</h3><p>Services are a core part of the OWL framework in Odoo. They provide a simple and structured way for components to interact with the <strong>backend, UI system, and application environment</strong>.</p><p>By using the useService hook, developers can easily access powerful tools such as:</p><ul><li>orm for database communication</li><li>action for navigation</li><li>notification and dialog for user feedback</li><li>hotkey and command for productivity features</li></ul><p>Understanding and using these services effectively allows developers to build <strong>powerful, interactive, and scalable frontend applications in Odoo</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dac78f3a92f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Owl Js — Hooks]]></title>
            <link>https://medium.com/@amritheshvenugopalan/basics-of-owl-js-hooks-32d091b07a4d?source=rss-0f9ec65df57d------2</link>
            <guid isPermaLink="false">https://medium.com/p/32d091b07a4d</guid>
            <category><![CDATA[owl-j]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[erp-software]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[odoo]]></category>
            <dc:creator><![CDATA[Amrithesh]]></dc:creator>
            <pubDate>Sun, 08 Mar 2026 07:37:30 GMT</pubDate>
            <atom:updated>2026-03-08T07:37:30.836Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uJPqNcQ9UqP8OGRXI_7_BQ.png" /></figure><h3>1. What Are Hooks in OWL?</h3><p>Hooks are special functions that allow components to interact with the OWL framework.</p><p>They help developers:</p><ul><li>Manage <strong>reactive state</strong></li><li>Access <strong>DOM elements</strong></li><li>Execute logic during <strong>component lifecycle events</strong></li><li>Perform <strong>side effects</strong> when data changes</li></ul><p>All hooks must be called inside the <strong>setup() method</strong> of a component.</p><h3>2. Lifecycle Hooks in OWL</h3><p>Lifecycle hooks allow you to execute code at different stages of a component’s life — from initialization to destruction.</p><p>These hooks are extremely useful when working with <strong>data fetching, UI updates, and cleanup tasks</strong>.</p><h3>2.1 onWillStart</h3><p>onWillStart runs <strong>before the component is rendered for the first time</strong>.</p><p>It is commonly used to <strong>load data from the server before displaying the UI</strong>.</p><p>If the function returns a <strong>Promise</strong>, OWL will wait until the promise resolves before rendering the component.</p><pre>import { Component, onWillStart } from &quot;@odoo/owl&quot;;<br>export class ExampleComponent extends Component {<br>    setup() {<br>        onWillStart(async () =&gt; {<br>           console.log(&quot;Component will start&quot;);<br>           // ADD COMPONENT LOGIC<br>        });<br>    }<br>}</pre><h3>When to use it</h3><ul><li>Fetch initial records</li><li>Load configuration data</li><li>Prepare data before rendering</li></ul><h3>2.2 onMounted</h3><p>onMounted runs <strong>after the component has been rendered and inserted into the DOM</strong>.</p><p>This hook is useful for:</p><ul><li>Focusing input fields</li><li>Initializing third-party libraries</li><li>Adding event listeners</li></ul><pre>import { onMounted, useRef } from &quot;@odoo/owl&quot;;<br><br>setup() {<br>    this.inputRef = useRef(&quot;searchInput&quot;);<br>    onMounted(() =&gt; {<br>        this.inputRef.el.focus();<br>    });<br>}</pre><h3>XML Template</h3><pre>&lt;input type=&quot;text&quot; t-ref=&quot;searchInput&quot;/&gt;</pre><p>Once the component appears on the screen, the input field will automatically receive focus.</p><h3>2.3 onWillUpdateProps</h3><p>This hook runs <strong>before the component receives updated props from its parent component</strong>.</p><p>It allows developers to react to incoming prop changes.</p><pre>import { onWillUpdateProps } from &quot;@odoo/owl&quot;;<br><br>setup() {<br>    onWillUpdateProps((nextProps) =&gt; {<br>        console.log(&quot;Props will update:&quot;, nextProps);<br>    });<br>}</pre><h3>When to use it</h3><ul><li>Detect changes from parent components</li><li>Prepare data before re-render</li></ul><h3>2.4 onPatched</h3><p>onPatched runs <strong>after the virtual DOM updates the real DOM</strong>.</p><p>It is useful when you need to run logic <strong>after the UI has been updated</strong>.</p><pre>import { onPatched } from &quot;@odoo/owl&quot;;<br><br>setup() {<br>    onPatched(() =&gt; {<br>        console.log(&quot;DOM updated&quot;);<br>    });<br>}</pre><h3>Common uses</h3><ul><li>Adjust scroll position</li><li>Update UI elements after rendering</li><li>Integrate external libraries</li></ul><h3>2.5 onWillUnmount</h3><p>This hook runs <strong>just before a component is removed from the DOM</strong>.</p><p>It is mainly used for <strong>cleanup tasks</strong>.</p><pre>import { onWillUnmount } from &quot;@odoo/owl&quot;;<br><br>setup() {<br>    onWillUnmount(() =&gt; {<br>        console.log(&quot;Component removed from DOM&quot;);<br>    });<br>}</pre><h3>Typical uses</h3><ul><li>Removing event listeners</li><li>Clearing timers</li></ul><h3>2.6 onWillDestroy</h3><p>onWillDestroy runs <strong>when the component is about to be completely destroyed</strong>.</p><p>It happens after onWillUnmount.</p><pre>import { onWillDestroy } from &quot;@odoo/owl&quot;;<br><br>setup() {<br>    onWillDestroy(() =&gt; {<br>        console.log(&quot;Component destroyed&quot;);<br>    });<br>}</pre><h3>3. State and Reactivity Hooks</h3><p>OWL provides hooks that help manage <strong>dynamic data inside components</strong>.</p><h3>3.1 useState</h3><p>useState creates <strong>reactive state</strong> inside a component.</p><p>Whenever a value inside the state changes, OWL <strong>automatically re-renders the component</strong>.</p><pre>/** @odoo-module **/<br><br>import { Component, useState } from &quot;@odoo/owl&quot;;<br>export class Counter extends Component {<br>    setup() {<br>        this.state = useState({<br>            value: 0,<br>        });<br>    }<br>    increase() {<br>        this.state.value++;<br>    }<br>}<br>Counter.template = &quot;owl_example.Counter&quot;;</pre><h3>XML Template</h3><pre>&lt;t t-name=&quot;owl_example.Counter&quot;&gt;<br>    &lt;div&gt;<br>        &lt;p&gt;Count: &lt;t t-esc=&quot;state.value&quot;/&gt;&lt;/p&gt;<br>        &lt;button t-on-click=&quot;increase&quot;&gt;Increase&lt;/button&gt;<br>    &lt;/div&gt;<br>&lt;/t&gt;</pre><p>Every time the button is clicked, the counter increases and the UI updates automatically.</p><h3>3.2 useEffect</h3><p>useEffect allows developers to run <strong>side effects</strong> whenever specific data changes.</p><p>It runs <strong>after the DOM has been updated</strong>.</p><pre>import { useEffect } from &quot;@odoo/owl&quot;;<br>setup() {<br>    this.state = useState({<br>        search: &quot;&quot;,<br>    });<br>    useEffect(<br>        () =&gt; {<br>            console.log(&quot;Search changed:&quot;, this.state.search);<br>        },<br>        () =&gt; [this.state.search]<br>    );<br>}</pre><h3>Explanation</h3><p>The effect runs only when <strong>state.search changes</strong>.</p><p>Typical use cases:</p><ul><li>API calls</li><li>Search filtering</li><li>Updating external services</li></ul><h3>3.3 useRef</h3><p>useRef provides a way to <strong>directly access DOM elements</strong> from a component.</p><p>This is useful when you need to interact with a specific HTML element.</p><h3>XML Template</h3><pre>&lt;input type=&quot;text&quot; t-ref=&quot;partnerSearch&quot;/&gt;</pre><pre>import { useRef, onMounted } from &quot;@odoo/owl&quot;;<br><br>setup() {<br>    this.partnerSearch = useRef(&quot;partnerSearch&quot;);<br>    onMounted(() =&gt; {<br>        this.partnerSearch.el.focus();<br>    });<br>}</pre><p>useRef gives access to the <strong>actual DOM element</strong> through .el.</p><h3>4. Best Practices When Using OWL Hooks</h3><p>When working with hooks in Odoo OWL, keep these best practices in mind:</p><ul><li>Always call hooks inside <strong>setup()</strong></li><li>Use <strong>onWillStart</strong> for server data loading</li><li>Use <strong>useState</strong> for reactive UI data</li><li>Avoid direct DOM manipulation unless necessary</li><li>Clean up resources using <strong>onWillUnmount</strong></li></ul><p>These practices help keep components <strong>clean, predictable, and maintainable</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32d091b07a4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Owl Js — Components]]></title>
            <link>https://medium.com/@amritheshvenugopalan/basics-of-owl-js-components-771a825a9f85?source=rss-0f9ec65df57d------2</link>
            <guid isPermaLink="false">https://medium.com/p/771a825a9f85</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[erp-software]]></category>
            <category><![CDATA[owl-j]]></category>
            <category><![CDATA[odoo-19]]></category>
            <dc:creator><![CDATA[Amrithesh]]></dc:creator>
            <pubDate>Sun, 08 Mar 2026 06:38:55 GMT</pubDate>
            <atom:updated>2026-03-08T06:38:55.627Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J-wmneQAoyhsnRIYO7tP6A.png" /></figure><h3>1. What is Owl in Odoo?</h3><p><strong>Owl (Odoo Web Library)</strong> is a modern JavaScript framework used in Odoo to build reactive UI components.</p><p>Instead of manipulating the DOM manually with JavaScript or jQuery, Owl lets developers build <strong>components</strong> that automatically update the UI whenever the data changes.</p><p>A component usually contains:</p><ul><li>A <strong>JavaScript class</strong> (logic)</li><li>An <strong>XML template</strong> (UI structure)</li><li>A <strong>state</strong> (dynamic data)</li></ul><p>This structure makes the UI <strong>modular, maintainable, and reusable</strong>.</p><h3>2. Why Do We Use Components?</h3><p>Components break complex interfaces into smaller reusable blocks.</p><p>For example, imagine a dashboard with:</p><ul><li>Search bar</li><li>Product list</li><li>Filters</li></ul><p>Instead of writing everything in a single large script, we can create multiple components:</p><ul><li>Dashboard</li><li>SearchBar</li><li>ProductList</li><li>Counter</li></ul><p>Each component manages its own UI and logic.</p><h3>Without Components</h3><p>Without a component system, developers often:</p><ul><li>Reload entire pages</li><li>Write manual DOM manipulation code</li><li>Struggle with maintainability</li></ul><h3>With Owl Components</h3><p>Owl uses a <strong>Virtual DOM</strong>.</p><p>When data changes:</p><ol><li>Owl detects the state change</li><li>Calculates what changed</li><li>Updates only the required DOM elements</li></ol><p>This results in <strong>fast and efficient UI updates</strong>.</p><h3>3. Creating a Simple Owl Component in Odoo</h3><p>Let’s build a <strong>simple counter component</strong>.</p><p>The user clicks a button to increase the counter value.</p><h3>Create the JavaScript Component</h3><p>Create a JS file:</p><pre>static/src/js/counter.js</pre><pre>/** @odoo-module **/<br>import { Component } from &quot;@odoo/owl&quot;;<br>export class Counter extends Component {<br>    <br>    setup() {<br>    }<br>}<br>Counter.template = &quot;owl_counter.Counter&quot;;</pre><ul><li>Component → Base Owl class for creating a component</li><li>setup() → Initializes component logic</li><li>template → Links the XML template</li></ul><h3>4. Creating the XML Template</h3><pre>static/src/xml/counter.xml</pre><pre>&lt;templates xml:space=&quot;preserve&quot;&gt;<br><br>    &lt;t t-name=&quot;owl_counter.Counter&quot;&gt;<br>        &lt;div class=&quot;counter_box&quot;&gt;<br>            &lt;h3&gt;Hello Owl Counter&lt;/h3&gt;<br>        &lt;/div&gt;<br>    &lt;/t&gt;<br><br>&lt;/templates&gt;</pre><p>t-name → Defines template name</p><h3>5. Registering the Component Using Registry</h3><p>To make the component usable in Odoo, we register it in a <strong>registry</strong>.</p><pre>static/src/js/counter.js</pre><pre>/** @odoo-module **/<br>import { Component } from &quot;@odoo/owl&quot;;<br>import { registry } from &quot;@web/core/registry&quot;;<br><br>export class Counter extends Component {<br>    <br>    setup() {<br>    }<br>}<br>Counter.template = &quot;owl_counter.Counter&quot;;<br>registry.category(&quot;actions&quot;).add(&quot;owl_counter_action&quot;, Counter);</pre><p>Registries in Odoo act like <strong>global containers</strong> where components, services, and actions are stored.</p><p>Here we register our component under the <strong>actions registry</strong>.</p><h3>6. Creating an Odoo Action</h3><p>Now we create a <strong>client action</strong> so Odoo knows when to load our component.</p><pre>&lt;record id=&quot;action_owl_counter&quot; model=&quot;ir.actions.client&quot;&gt;<br>    &lt;field name=&quot;name&quot;&gt;Owl Counter&lt;/field&gt;<br>    &lt;field name=&quot;tag&quot;&gt;owl_counter_action&lt;/field&gt;<br>&lt;/record&gt;</pre><p>When the client action is called:</p><ol><li>Odoo reads the <strong>action tag</strong></li><li>Looks inside the <strong>actions registry</strong></li><li>Finds the Counter component</li><li>Mounts it automatically</li></ol><h3>7. Adding Web Assets</h3><p>To load our JavaScript and XML files, we must add them in the module manifest.</p><pre>&#39;assets&#39;: {<br>    &#39;web.assets_backend&#39;: [<br>        &#39;owl_counter/static/src/js/counter.js&#39;,<br>        &#39;owl_counter/static/src/xml/counter.xml&#39;,<br>    ],<br>}</pre><h3>Asset Bundles in Odoo</h3><ul><li>web.assets_backend → Used For loading Backend applications related assets</li><li>web.assets_frontend → Used for loading Website / eCommerce related assets</li><li>web.assets_point_of_sale → Used for loading POS related assets</li></ul><h3>8. <strong>Static Properties in Components</strong></h3><p>When defining an Owl component, we often rely on various static properties to define its identity and dependencies.</p><pre>/** @odoo-module **/<br>import { Component } from &quot;@odoo/owl&quot;;<br>import { Navbar } from &quot;COMPONENT PATH&quot;;<br><br>export class Counter extends Component {<br>    static components = { Navbar };<br>    static props = {<br>            message: { type: String, optional: true },<br>        };<br>    setup() {<br>    }<br>}<br>Counter.template = &quot;owl_counter.Counter&quot;;</pre><ul><li>static components → If your template uses other custom sub-components, you must register them here.</li><li>static props→ Props (Properties) define the expected data being passed down from a parent component. You can enforce type checking and specify if a prop is optional.</li><li>static defaultProps → If a prop is optional and the parent component doesn’t provide it, `defaultProps` helps define a fallback baseline value, preventing unexpected crashes.</li><li>static template → Another way to define the XML template that the component will render.</li></ul><h3>9. Patch vs Extend Components</h3><p>When customizing Odoo components, two approaches are common.</p><h3>Extend</h3><p>Create a new component based on an existing one.</p><pre>export class MyCounter extends Counter {<br>}</pre><h3>Patch</h3><p>Modify an existing component without creating a new one.</p><pre>import { patch } from &quot;@web/core/utils/patch&quot;;<br>import { Counter } from &quot;COMPONENT PATH&quot;;</pre><pre>patch(Counter.prototype, {</pre><pre>});</pre><p>Patching is widely used in <strong>Odoo customizations</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=771a825a9f85" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>