<?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 Osama Alhalabi on Medium]]></title>
        <description><![CDATA[Stories by Osama Alhalabi on Medium]]></description>
        <link>https://medium.com/@eng.osama1998?source=rss-26a0731ee4f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oONFjMt0JpZg2QBnDODQUg.png</url>
            <title>Stories by Osama Alhalabi on Medium</title>
            <link>https://medium.com/@eng.osama1998?source=rss-26a0731ee4f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 05:57:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eng.osama1998/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[Odoo Migration Decoded, Part 3: The Odoo.sh Upgrade (16 → 19)]]></title>
            <link>https://medium.com/@eng.osama1998/odoo-migration-decoded-part-3-the-odoo-sh-upgrade-16-19-b7259319ae5c?source=rss-26a0731ee4f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7259319ae5c</guid>
            <category><![CDATA[crm-data-migration]]></category>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[odoo-16]]></category>
            <category><![CDATA[odoo-migration]]></category>
            <category><![CDATA[odoo-erp]]></category>
            <dc:creator><![CDATA[Osama Alhalabi]]></dc:creator>
            <pubDate>Wed, 03 Jun 2026 08:16:55 GMT</pubDate>
            <atom:updated>2026-06-03T08:16:55.518Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9WHzAPyHHpHu5zYUPR3tmg.jpeg" /></figure><p>The operations manual nobody documents — triggering the upgrade, the Rebuild trap, and recovering when the database fights back.</p><p>Parts 1 and 2 of <em>Odoo Migration Decoded</em> covered the <strong>code</strong> — the ORM, view, and controller changes, and the OWL/JS rewrites that break your modules on the way from 16 to 19. This part covers the half nobody writes about: the <strong>Odoo.sh platform workflow</strong> for actually shipping that upgrade across <strong>staging and production</strong>.</p><p>It looks like one button. It isn’t. Below is the real flow — how the upgrade is triggered, how the special “upgrade mode” lets you iterate, what the <strong>Exit Test Upgrade </strong>and <strong>Rebuild</strong> buttons truly do, and the mistakes that cost us a database (so they don’t cost you one).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ol-i6G9_gexptuLkYCZWPg.png" /><figcaption>The end-to-end upgrade pipeline</figcaption></figure><h3>1. How Odoo.sh actually does the upgrade</h3><p>Odoo.sh is wired directly into Odoo’s <strong>Upgrade platform</strong>. You don’t run openupgrade or restore dumps by hand. The mechanism is:</p><ol><li>Your <strong>latest daily production backup</strong> has been shipped to the upgrade platform.</li><li>The platform runs the <strong>core/base upgrade</strong> (standard modules + DB schema scripts) against that backup.</li><li>The upgraded backup lands back on your branch, which then enters a special <strong>“upgrade mode”</strong>: <em>every commit you push</em> re-restores the upgraded backup and re-runs an update of <strong>all custom modules</strong>.</li></ol><blockquote><strong><em>Key prerequisite:</em></strong><em> your custom modules’ source code must already be ported to 18.0 </em>before<em> you start. The platform upgrades core; you are responsible for the custom code.</em></blockquote><h3>2. The staging test, step by step</h3><ol><li><strong>Port your custom code first.</strong> Bump manifests to 18.0 and fix the code-level breakage (attrs/states → inline expressions, OWL/JS rewrites, removed APIs — everything from Parts 1 &amp; 2).</li><li><strong>Create a dedicated upgrade branch</strong> (staging tier) and push your ported code.</li><li><strong>Trigger the test upgrade.</strong> On your <strong>staging (upgrade) branch → Upgrade</strong> tab, select the target version (18.0) and click <strong>Test Upgrade</strong>. (The same button reads <strong>Start Upgrade</strong> only on the production branch.) Your latest production backup is shipped to the upgrade platform.</li><li><strong>Core upgrade runs.</strong> If it fails <em>here</em>, the cause is almost always core modules / DB scripts → that’s Odoo’s side, contact Support.</li><li><strong>Push an empty commit</strong> to trigger the custom-module upgrade. Errors after this point are <em>your</em> code.</li><li><strong>Read</strong> ~/logs/upgrade.log.</li><li><strong>Functional testing</strong> once it’s green.</li><li><strong>Mind the 30-day window</strong> — special mode auto-closes after 30 days.</li></ol><pre># Step 5 — the literal trigger for your custom modules<br>git commit --allow-empty -m &quot;trigger custom module upgrade&quot;<br>git push</pre><h3>3. The “Exit upgrade test” button</h3><p>While a staging branch is in upgrade mode, <strong>every push wipes the DB and re-restores the upgraded backup</strong>. Great for iterating — destructive to any manual test data you enter.</p><p><strong>Exit / Disable upgrade mode</strong> takes the branch out of that restore-on-every-commit loop and returns it to a <strong>normal staging branch</strong>: the current upgraded DB is kept, and future pushes just do a normal incremental update — no more wipes.</p><h3>Does the version stay on 18 after exiting? — Yes.</h3><p>Two separate things are in play; the Exit button only touches one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cC0GzC0ID99UgVed9Ojpvg.png" /></figure><p>So you walk away with a <strong>normal staging branch already on 18, holding your migrated data</strong> — ready for UAT.</p><blockquote><strong><em>Rule of thumb:</em></strong><em> stay in upgrade mode while you’re still fixing migration scripts; exit only once the upgrade is solid and you’re moving into functional UAT. The trade-off: after exiting, getting a fresh upgraded backup means re-triggering the upgrade, not just pushing.</em></blockquote><h3>4. The “Rebuild” button — and the trap that loses your migrated DB</h3><p><strong>Rebuild is not version control.</strong> It fetches the <strong>latest production daily backup</strong> (the data) and applies the <strong>current branch’s code</strong> on top. So the resulting version depends on <strong>which production version is in use</strong> — not the branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*losn_P3IrH0j4HqB7KMHKA.png" /></figure><p>The confusion comes from three different “reset” actions that look similar but do very different things:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*12s_LzrgpWm3tyMME0y8Fg.png" /></figure><h3>5. Shipping to production</h3><ul><li>Confirm the staging upgrade status is <strong>successful</strong> first.</li><li>On the <strong>Production branch → Upgrade</strong> tab, run the same flow but select <strong>Production</strong> as the purpose. It takes a fresh prod backup, upgrades it, and restores it as the live DB.</li><li><strong>Schedule it during a low-activity window</strong> — production is briefly down during the restore. Take a manual backup beforehand.</li></ul><h3>6. What we messed up — and how we recovered</h3><p>The honest part. Two of these bit us directly; all five are worth knowing.</p><h3>① Rebuilt after exiting upgrade mode → lost the migrated v18 DB</h3><p><strong>What happened:</strong> Rebuild pulled the latest production backup (still v16) over our v18 staging DB. The migrated database and all test data — gone. <strong>Recovery:</strong> re-trigger the upgrade to regenerate a fresh upgraded backup (or restore a dump you took beforehand). <strong>Prevent:</strong> download a DB dump before <em>any</em> Rebuild on an upgraded branch.</p><h3>② Leftover references from dropped modules — “field not defined / view not found”</h3><p><strong>What happened:</strong> we dropped and uninstalled several modules, but the database still held <strong>orphaned records</strong> pointing back at them — stale fields, views, and model metadata. The upgrade then failed with <em>field not defined</em> and <em>view not found</em> errors. <strong>How we recovered:</strong> we connected to the <strong>staging branch over SSH</strong> and ran a cleanup script that purged the residual data left behind (the dropped modules’ ir.model.fields, ir.ui.view, and ir.model.data records), then re-ran the upgrade — clean. <strong>Prevent:</strong> uninstalling from the UI doesn’t remove every dependent record. Fully retire a dropped module — uninstall it, delete it from the <strong>Apps</strong> list, and clean its orphaned metadata.</p><h3>③ Core (base) upgrade fails</h3><p>Not your code. Read ~/logs/upgrade.log and contact Odoo Support — don’t burn hours debugging core errors as if they were yours.</p><h3>④ The 30-day special mode expired mid-test</h3><p>The restore-on-commit loop silently stops. Re-trigger the upgrade to resume. Track the clock and exit deliberately once stable.</p><h3>⑤ Upgraded production too early</h3><p>Regressions surfaced live. Recovery means restoring a pre-upgrade backup — which rolls back <strong>both data and version</strong>, losing any transactions since cutover. Sign off on UAT first; back up immediately before cutover.</p><blockquote><strong><em>Headline lesson:</em></strong><em> always download a DB dump before clicking Rebuild or Restore. Odoo.sh has no “undo.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TH5oTc4yqWxw01Rn3sgdoA.png" /></figure><h3>8. FAQ</h3><h3>Can I jump straight from 16 → 18 (skip 17), and can I roll back?</h3><p>You select the target (18) and the platform migrates sequentially under the hood (16 → 17 → 18). You <strong>can’t skip</strong> that schema chain, and you <strong>can’t revert</strong> an upgraded DB. The only rollback is restoring a pre-upgrade backup — so always keep one.</p><h3>A module shows as installed in the DB but is gone from my repo and blocks the upgrade.</h3><p>Three steps:</p><p>(1) mark it uninstalled — UPDATE ir_module_module SET state=&#39;uninstalled&#39; WHERE id IN (…); or ship an empty stub module; (2) remove it from the repo; (3) delete it from the <strong>Apps</strong> list so the upgrade won’t pick it up again. Then re-push.</p><h3>Where do custom migration scripts go?</h3><p>Inside the module at migrations/&lt;version&gt;/pre-migrate.py and post-migrate.py (pre- before the module update, post- after). In upgrade mode, every push re-runs them — commit, check the log, fix, recommit.</p><h3>Will I lose data during the upgrade?</h3><p>The upgrade works on a <em>copy</em>, so production isn’t mutated during the staging test. The real risks are the <strong>filestore</strong> (attachments aren’t in the SQL dump) and an accidental Rebuild/Restore. Download a full backup (DB + filestore) before any production upgrade.</p><blockquote><strong><em>A note on accuracy:</em></strong><em> the Exit-button behavior and the in-upgrade-mode Rebuild behavior aren’t crisply documented by Odoo — they’re inferred from how the platform works and confirmed by doing it for real. Your own build logs are the authoritative source.</em></blockquote><p>And that’s it. Upgrading on Odoo.sh isn’t hard — it’s just unforgiving. The platform does the heavy lifting; your job is mostly to not click Rebuild at the worst possible moment. Take the backup, read the log, exit on your own terms, and resist the urge to “just refresh the data real quick.” Future-you, staring at a v16 database where your migration used to be, will thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7259319ae5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Real-Time POS Analytics Dashboard for Odoo — A Step-by-Step Guide]]></title>
            <link>https://medium.com/@eng.osama1998/building-a-real-time-pos-analytics-dashboard-for-odoo-a-step-by-step-guide-e1b0c9a89e10?source=rss-26a0731ee4f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1b0c9a89e10</guid>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[odoo-implementation]]></category>
            <category><![CDATA[odoo-19]]></category>
            <category><![CDATA[odoo-development]]></category>
            <category><![CDATA[odoo-erp]]></category>
            <dc:creator><![CDATA[Osama Alhalabi]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 09:10:40 GMT</pubDate>
            <atom:updated>2026-03-31T09:10:40.952Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dOcWq26LCfU6ndZLYJusfA.png" /></figure><p>A step-by-step tutorial using OWL 2, Chart.js, and zero extra database models. Works on Odoo 17, 18, and 19.</p><p>If you’ve ever opened Odoo’s built-in POS reports and thought, <em>“This tells me what happened last month, but what about right now?”</em> — you’re not alone.</p><p>Odoo ships with solid transactional reporting, but it lacks a <strong>live, at-a-glance analytics dashboard</strong> for POS managers. The kind where you walk into the store, open one screen, and immediately know: how much did we sell today? Which product is flying off the shelves? Which register is on fire (the good kind)?</p><p>That’s exactly what <strong>POS Dashboard Mini</strong> solves — a minimal module that packs 4 KPI cards and 4 interactive charts into a clean, lightweight codebase. No extra database models. No cron jobs. No performance overhead. Just a single JSON endpoint and an OWL 2 component that renders everything in the browser.</p><p>This tutorial walks you through exactly how it’s built, piece by piece. By the end, you’ll have a working dashboard <em>and</em> a reusable pattern you can apply to any Odoo reporting project.</p><blockquote>This module works on <strong>Odoo 17, 18, and 19</strong>. The OWL 2 API and controller patterns are identical across all three versions.</blockquote><h3>🛠️ What We’re Building</h3><p>Before we write a single line of code, let’s look at what the finished dashboard delivers. The entire module rests on <strong>three pillars</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sb_UQHUuAjWLqibsWz8zFA.png" /><figcaption>The three pillars behind our real-time POS dashboard architecture.</figcaption></figure><p>And here’s the actual result — the finished dashboard running inside Odoo with live POS data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s3Vv7LaY_2S7t5kdAlYT1A.png" /><figcaption>The finished POS Dashboard Mini in action — 4 KPIs and 4 interactive charts, all powered by live data.</figcaption></figure><p><strong>4 KPI Cards</strong> give you the instant numbers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*6gw-f3MLz10vrdi6FGw3BQ.png" /></figure><p><strong>4 Charts</strong> give you the visual story: a daily <strong>Sales Trend</strong> line chart, a horizontal bar for <strong>Top 10 Products</strong>, a vertical bar for <strong>Sales by POS</strong> location, and a <strong>Payment Methods</strong> doughnut.</p><h3>🏗️ Architecture: The Zero-Model Approach</h3><p>Here’s what most Odoo developers don’t expect: <strong>this module creates zero new database models</strong>. No ir.model records. No migrations. No stored computed fields hogging your cron queue.</p><p>Instead, everything flows through three layers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oP9PmyMLDgQWZaaas_zOlg.png" /><figcaption>No extra database models · No cron jobs · No stored fields · Pure read_group() aggregation</figcaption></figure><p>The controller queries Odoo’s existing pos.order, pos.order.line, and pos.payment models using read_group() — the ORM&#39;s built-in SQL aggregation method. The result is a single JSON blob that the OWL component consumes and passes to Chart.js for rendering.</p><p>Think of it like a news ticker: the data already exists in Odoo’s database. We’re just asking better questions and presenting the answers beautifully.</p><h3>📝 Step 1 — Module Skeleton</h3><p>Let’s start with the scaffolding. Here’s the complete file structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*_dyBO4MLYagTg8BDzELFuQ.png" /></figure><p>Seven files. That’s the entire module. Let’s start with the manifest:</p><pre>{<br>    &#39;name&#39;: &#39;POS Dashboard Mini&#39;,<br>    &#39;version&#39;: &#39;19.0.1.0.0&#39;,<br>    &#39;summary&#39;: &#39;Minimal POS analytics dashboard with 4 KPIs and 4 charts&#39;,<br>    &#39;category&#39;: &#39;Point of Sale/Reporting&#39;,<br>    &#39;author&#39;: &#39;Eng. Osama Alhalabi&#39;,<br>    &#39;website&#39;: &#39;https://www.osamaalhalabi.tech&#39;,<br>    &#39;license&#39;: &#39;OPL-1&#39;,<br>    &#39;depends&#39;: [&#39;point_of_sale&#39;],<br>    &#39;data&#39;: [<br>        &#39;views/dashboard_menu.xml&#39;,<br>    ],<br>    &#39;assets&#39;: {<br>        &#39;web.assets_backend&#39;: [<br>            &#39;pos_dashboard_mini/static/src/scss/dashboard.scss&#39;,<br>            &#39;pos_dashboard_mini/static/src/xml/dashboard.xml&#39;,<br>            &#39;pos_dashboard_mini/static/src/js/dashboard.js&#39;,<br>        ],<br>    },<br>    &#39;installable&#39;: True,<br>    &#39;application&#39;: True,<br>}</pre><p>Two things to notice here. First, the <strong>only dependency</strong> is point_of_sale. Second, we register our frontend assets (SCSS, XML template, JS) through the web.assets_backend bundle — this is the standard OWL 2 pattern since Odoo 17.</p><p>The menu registration is equally minimal:</p><pre>&lt;odoo&gt;<br>    &lt;record id=&quot;action_pos_dashboard_mini&quot; model=&quot;ir.actions.client&quot;&gt;<br>        &lt;field name=&quot;name&quot;&gt;POS Dashboard Mini&lt;/field&gt;<br>        &lt;field name=&quot;tag&quot;&gt;pos_dashboard_mini&lt;/field&gt;<br>    &lt;/record&gt;<br>    &lt;menuitem id=&quot;menu_pos_dashboard_mini_root&quot;<br>              name=&quot;POS Dashboard&quot;<br>              action=&quot;action_pos_dashboard_mini&quot;<br>              web_icon=&quot;pos_dashboard_mini,static/description/icon.png&quot;<br>              sequence=&quot;8&quot;/&gt;<br>&lt;/odoo&gt;</pre><p>We use ir.actions.client with a tag that matches the registry key we&#39;ll set in JavaScript. This tells Odoo: &quot;When the user clicks this menu, render our OWL component.&quot;</p><h3>🚀 Step 2 — The Backend Controller</h3><p>This is where the data magic happens. One controller, one endpoint, four aggregation queries:</p><pre>from odoo import http<br>from odoo.http import request<br>from datetime import date<br><br><br>class PosDashboardMiniController(http.Controller):<br><br>    @http.route(&#39;/pos_dashboard_mini/data&#39;, type=&#39;json&#39;, auth=&#39;user&#39;)<br>    def get_data(self):<br>        today = date.today()<br>        date_from = today.replace(day=1)   # first day of current month<br>        date_to = today<br>        return {<br>            &#39;kpis&#39;: self._get_kpis(date_from, date_to),<br>            &#39;charts&#39;: self._get_charts(date_from, date_to),<br>        }</pre><p>Notice: type=&#39;json&#39; means Odoo handles JSON serialization and CSRF protection automatically. The auth=&#39;user&#39; ensures only logged-in users can access the data.</p><h3>The read_group() Pattern</h3><p>The real workhorse is read_group() — Odoo&#39;s ORM method that translates directly into SQL GROUP BY queries. Instead of fetching thousands of order records and summing them in Python, we let PostgreSQL do the heavy lifting:</p><pre>def _get_kpis(self, date_from, date_to):<br>    Order = request.env[&#39;pos.order&#39;].sudo()<br>    domain = self._base_domain(date_from, date_to)<br><br>    # Single aggregation call -- becomes one SQL query<br>    agg = Order.read_group(domain, [&#39;amount_total&#39;], [])<br>    total_sales = agg[0][&#39;amount_total&#39;] if agg else 0<br>    order_count = agg[0][&#39;__count&#39;] if agg else 0<br>    avg_order = total_sales / order_count if order_count else 0</pre><p>For the chart data, the same pattern applies. Group sales by day for the trend chart, by product for the top-10 bar chart, by POS config for the location comparison, and by payment method for the doughnut:</p><pre>def _chart_sales_trend(self, date_from, date_to):<br>    Order = request.env[&#39;pos.order&#39;].sudo()<br>    data = Order.read_group(<br>        self._base_domain(date_from, date_to),<br>        [&#39;amount_total&#39;], [&#39;date_order:day&#39;])<br>    return {<br>        &#39;labels&#39;: [r[&#39;date_order:day&#39;] for r in data],<br>        &#39;values&#39;: [r[&#39;amount_total&#39;] for r in data],<br>    }</pre><p>The &#39;date_order:day&#39; syntax is Odoo&#39;s built-in date grouping — it groups by calendar day without any manual date parsing. You can also use :week, :month, or :quarter.</p><h3>🎨 Step 3 — The OWL 2 Component</h3><p>Now for the frontend. Our OWL component does three things: fetches data via RPC, manages reactive state, and renders Chart.js instances:</p><pre>/** @odoo-module **/<br>import { Component, useState, useRef, onMounted, onWillUnmount }<br>    from &quot;@odoo/owl&quot;;<br>import { registry } from &quot;@web/core/registry&quot;;<br>import { useService } from &quot;@web/core/utils/hooks&quot;;<br><br>const PALETTE = [<br>    &#39;#4285F4&#39;, &#39;#5B9BF0&#39;, &#39;#90B8F8&#39;, &#39;#A0C4FC&#39;, &#39;#2B6CB0&#39;,<br>    &#39;#63B3ED&#39;, &#39;#2C5282&#39;, &#39;#4A7CC9&#39;, &#39;#BEE3F8&#39;, &#39;#3B6AA0&#39;,<br>];<br><br>class PosDashboardMini extends Component {<br>    static template = &quot;pos_dashboard_mini.Dashboard&quot;;<br><br>    setup() {<br>        this.rpc = useService(&quot;rpc&quot;);<br>        this.action = useService(&quot;action&quot;);<br>        this.state = useState({ loading: true, kpis: [], charts: {} });<br>        this.chartRefs = {<br>            salesTrend:      useRef(&quot;salesTrendChart&quot;),<br>            topProducts:     useRef(&quot;topProductsChart&quot;),<br>            salesByPos:      useRef(&quot;salesByPosChart&quot;),<br>            paymentMethods:  useRef(&quot;paymentMethodsChart&quot;),<br>        };<br>        this.chartInstances = {};<br>        onMounted(() =&gt; this._onMounted());<br>        onWillUnmount(() =&gt; this._destroyCharts());<br>    }<br><br>    async _onMounted() {<br>        await this._loadChartJs();<br>        await this.loadData();<br>    }<br>}</pre><p>Key details worth highlighting:</p><ul><li><strong>useState()</strong> creates a reactive proxy. When this.state.loading changes, OWL automatically re-renders the affected DOM nodes — no manual DOM manipulation needed.</li><li><strong>useRef()</strong> gives us direct access to the &lt;canvas&gt; elements for Chart.js initialization.</li><li><strong>Chart.js is loaded from CDN</strong> on first mount, avoiding the need to bundle a 200KB library in Odoo’s asset pipeline.</li></ul><p>The component also includes a <strong>dark mode observer</strong> that watches for Odoo’s theme class changes on &lt;html&gt; and re-renders all charts with updated colors. This is a small touch, but it makes the dashboard feel native:</p><pre>_observeTheme() {<br>    this._observer = new MutationObserver(() =&gt; this.renderAllCharts());<br>    this._observer.observe(document.documentElement,<br>        { attributes: true, attributeFilter: [&#39;class&#39;] });<br>}</pre><h3>🎨 Step 4 — Template &amp; Styling</h3><p>The OWL XML template is declarative and clean. KPI cards are rendered in a loop, and each chart gets its own canvas:</p><pre>&lt;templates xml:space=&quot;preserve&quot;&gt;<br>  &lt;t t-name=&quot;pos_dashboard_mini.Dashboard&quot;&gt;<br>    &lt;div class=&quot;pdm-container&quot;&gt;<br>      &lt;div class=&quot;pdm-kpi-grid&quot;&gt;<br>        &lt;t t-foreach=&quot;state.kpis&quot; t-as=&quot;kpi&quot; t-key=&quot;kpi.id&quot;&gt;<br>          &lt;div class=&quot;pdm-kpi-card&quot;<br>               t-att-class=&quot;&#39;pdm-border-&#39; + kpi.color&quot;<br>               t-on-click=&quot;() =&gt; this.onKpiClick(kpi.id)&quot;&gt;<br>            &lt;div class=&quot;pdm-kpi-icon&quot;<br>                 t-att-class=&quot;&#39;pdm-color-&#39; + kpi.color&quot;&gt;<br>              &lt;i t-att-class=&quot;&#39;fa &#39; + kpi.icon&quot;/&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;pdm-kpi-body&quot;&gt;<br>              &lt;div class=&quot;pdm-kpi-label&quot; t-esc=&quot;kpi.name&quot;/&gt;<br>              &lt;div class=&quot;pdm-kpi-value&quot; t-esc=&quot;kpi.value&quot;/&gt;<br>            &lt;/div&gt;<br>          &lt;/div&gt;<br>        &lt;/t&gt;<br>      &lt;/div&gt;<br>      &lt;div class=&quot;pdm-charts-grid&quot;&gt;<br>        &lt;div class=&quot;pdm-chart-card&quot;&gt;<br>          &lt;h6&gt;Sales Trend&lt;/h6&gt;<br>          &lt;canvas t-ref=&quot;salesTrendChart&quot;/&gt;<br>        &lt;/div&gt;<br>        &lt;!-- ... three more chart cards --&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/t&gt;<br>&lt;/templates&gt;</pre><p>The SCSS uses CSS Grid with auto-fit for a responsive layout that works on any screen width:</p><pre>.pdm-container { padding: 24px; max-width: 1400px; margin: auto; }<br>.pdm-kpi-grid {<br>    display: grid;<br>    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));<br>    gap: 16px;<br>    margin-bottom: 24px;<br>}<br>.pdm-kpi-card {<br>    display: flex; align-items: center; gap: 16px;<br>    padding: 20px; border-radius: 12px;<br>    border-left: 4px solid;<br>    cursor: pointer;<br>    transition: transform 0.15s, box-shadow 0.15s;<br>}<br>.pdm-kpi-card:hover {<br>    transform: translateY(-2px);<br>    box-shadow: 0 4px 12px rgba(0,0,0,.1);<br>}<br>.pdm-charts-grid {<br>    display: grid;<br>    grid-template-columns: repeat(2, 1fr);<br>    gap: 16px;<br>}<br>@media (max-width: 768px) {<br>    .pdm-charts-grid { grid-template-columns: 1fr; }<br>}</pre><p>No framework, no Tailwind, no build step. Just a handful of SCSS rules that Odoo compiles automatically.</p><h3>💡 Key Takeaways</h3><p>Building this dashboard reinforced a few principles I keep coming back to in Odoo development:</p><ul><li><strong>Zero database overhead.</strong> By relying entirely on read_group() against existing models, we add no migration burden and no storage cost. The module installs in seconds and uninstalls cleanly.</li><li><strong>The read_group() pattern is your best friend.</strong> If you’re writing Python loops to sum order totals, stop. Let PostgreSQL do it. The :day, :week, and :month grouping syntax alone can replace tons of date-parsing logic.</li><li><strong>OWL 2’s reactivity model is simple and powerful.</strong> useState() + useRef() + useService() — these three hooks cover 90% of dashboard use cases.</li><li><strong>Dark mode isn’t optional anymore.</strong> A one-line MutationObserver on the root element makes your component theme-aware with zero effort.</li><li><strong>CDN-loading Chart.js is the right call.</strong> Bundling it in Odoo’s asset pipeline bloats every page. Loading it on-demand means only dashboard users pay the cost.</li></ul><h3>🙌 Your Turn</h3><p>If you found this useful, what would you add to the dashboard? Payment trends over time? Cashier performance metrics? Drop a comment below.</p><p>And if you’re building Odoo modules and want more deep-dive tutorials like this, follow me here on Medium or connect on <a href="http://www.linkedin.com/in/osama-alhalabi-56b4181a8"><em>LinkedIn (Osama Alhalabi)</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1b0c9a89e10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Real-Time Dashboard in Odoo with OWL and Chart.js]]></title>
            <link>https://medium.com/@eng.osama1998/build-a-real-time-dashboard-in-odoo-with-owl-and-chart-js-1dc3d672e4c3?source=rss-26a0731ee4f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dc3d672e4c3</guid>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[odoo-17]]></category>
            <category><![CDATA[odoo18]]></category>
            <category><![CDATA[odoo-erp]]></category>
            <category><![CDATA[odoo-19]]></category>
            <dc:creator><![CDATA[Osama Alhalabi]]></dc:creator>
            <pubDate>Thu, 26 Mar 2026 08:22:57 GMT</pubDate>
            <atom:updated>2026-03-26T08:22:57.961Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oUnDlw0y1zG13lMWAx8MnQ.png" /></figure><p>A step-by-step tutorial: Python model, controller, OWL component, and XML template — everything you need to add interactive charts to Odoo.</p><p>Odoo gives you powerful models, views, and reports out of the box. But when a manager asks “show me production KPIs and inventory charts on one screen,” you need to build a custom dashboard.</p><p>The good news: Odoo (versions 17, 18, and 19) ships with OWL 2.x and a bundled copy of Chart.js. You don’t need npm, webpack, or any external dependency. In this tutorial, we’ll walk through building a dashboard from scratch — covering the controller, OWL component, and XML template.</p><blockquote>By the end of this article, you’ll know how to create any OWL-based dashboard in Odoo — whether it’s for sales, HR, inventory, or manufacturing. The same approach works across Odoo 17, 18, and 19.</blockquote><h3>Architecture at a Glance</h3><p>A custom dashboard in Odoo is surprisingly simple. It has four layers, each doing one job:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dk83cRBkBDFqFG71-TeBHw.png" /></figure><p>The data flow is straightforward: the OWL component calls the controller via fetch(), the controller queries Odoo models with read_group(), and returns JSON. Chart.js renders the data on &lt;canvas&gt; elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6LntfHYoVjyTg2sbJICnZw.png" /><figcaption>How the OWL component, controller, and ORM connect to serve live dashboard data.</figcaption></figure><h3>Step 1: The Controller — Serve Chart Data</h3><p>The controller is where your dashboard logic lives. It queries Odoo models and returns structured data that the frontend can render directly. Here’s a simple example:</p><p><strong>controllers/main.py</strong></p><pre>from odoo import http<br>from odoo.http import request<br><br>class DashboardController(http.Controller):<br><br>    @http.route(<br>        &#39;/my_dashboard/statistics&#39;,<br>        type=&#39;jsonrpc&#39;, auth=&#39;user&#39;, methods=[&#39;POST&#39;],<br>    )<br>    def get_statistics(self, **kwargs):<br>        # KPI: count of confirmed sale orders<br>        confirmed = request.env[&#39;sale.order&#39;].search_count([<br>            (&#39;state&#39;, &#39;=&#39;, &#39;sale&#39;),<br>        ])<br><br>        # Chart: revenue grouped by month<br>        revenue_data = request.env[&#39;sale.order&#39;].read_group(<br>            [(&#39;state&#39;, &#39;=&#39;, &#39;sale&#39;)],<br>            [&#39;amount_total&#39;],<br>            [&#39;date_order:month&#39;],<br>        )<br><br>        return {<br>            &#39;kpis&#39;: {&#39;confirmed_orders&#39;: confirmed},<br>            &#39;charts&#39;: {<br>                &#39;revenue_by_month&#39;: {<br>                    &#39;labels&#39;: [r[&#39;date_order:month&#39;] for r in revenue_data],<br>                    &#39;data&#39;: [r[&#39;amount_total&#39;] for r in revenue_data],<br>                },<br>            },<br>        }</pre><p>Two key Odoo ORM methods to know:</p><ul><li>search_count() — generates a SELECT COUNT(*) query. Fast and efficient for KPIs.</li><li>read_group() — generates a SELECT ... GROUP BY query. Perfect for chart data because you get aggregated results in a single SQL call instead of looping over records in Python.</li></ul><p>Notice the type=&#39;jsonrpc&#39; routing — this is Odoo&#39;s preferred way to expose JSON endpoints (available in Odoo 17+). The controller automatically handles request parsing and response formatting.</p><h3>Step 2: The OWL Component — Fetch and Render</h3><p>The OWL component is a single JavaScript class that fetches data from the controller and renders Chart.js charts. Here is the core structure:</p><p><strong>static/src/js/dashboard.js</strong></p><pre>/** @odoo-module **/<br><br>import { Component, useState, onWillStart,<br>         onMounted, onWillUnmount, useRef } from &quot;@odoo/owl&quot;;<br>import { registry } from &quot;@web/core/registry&quot;;<br>import { loadJS } from &quot;@web/core/assets&quot;;<br><br>export class MyDashboard extends Component {<br>    static template = &quot;my_module.Dashboard&quot;;<br>    static props = [&quot;*&quot;];<br><br>    setup() {<br>        this.state = useState({<br>            loading: true,<br>            kpis: {},<br>            charts: {},<br>        });<br><br>        // Ref to the canvas element in the template<br>        this.revenueChartRef = useRef(&quot;revenueChart&quot;);<br>        this.chartInstance = null;<br><br>        onWillStart(async () =&gt; {<br>            // Load Chart.js from Odoo&#39;s bundled copy<br>            await loadJS(&quot;/web/static/lib/Chart/Chart.js&quot;);<br>            await this.loadData();<br>        });<br><br>        onMounted(() =&gt; this.renderChart());<br>        onWillUnmount(() =&gt; {<br>            if (this.chartInstance) this.chartInstance.destroy();<br>        });<br>    }<br><br>    async loadData() {<br>        const response = await fetch(&quot;/my_dashboard/statistics&quot;, {<br>            method: &quot;POST&quot;,<br>            headers: { &quot;Content-Type&quot;: &quot;application/json&quot; },<br>            body: JSON.stringify({<br>                jsonrpc: &quot;2.0&quot;,<br>                method: &quot;call&quot;,<br>                params: {},<br>            }),<br>        });<br>        const json = await response.json();<br>        const data = json.result || {};<br>        this.state.kpis = data.kpis || {};<br>        this.state.charts = data.charts || {};<br>        this.state.loading = false;<br>    }<br><br>    renderChart() {<br>        const canvas = this.revenueChartRef.el;<br>        if (!canvas) return;<br>        const data = this.state.charts.revenue_by_month;<br><br>        this.chartInstance = new Chart(canvas.getContext(&quot;2d&quot;), {<br>            type: &quot;bar&quot;,<br>            data: {<br>                labels: data.labels,<br>                datasets: [{<br>                    label: &quot;Revenue&quot;,<br>                    data: data.data,<br>                    backgroundColor: &quot;#7C6CFF&quot;,<br>                    borderRadius: 6,<br>                }],<br>            },<br>            options: {<br>                responsive: true,<br>                maintainAspectRatio: false,<br>            },<br>        });<br>    }<br>}<br><br>// Register as Odoo client action<br>registry.category(&quot;actions&quot;).add(&quot;my_dashboard&quot;, MyDashboard);</pre><p>Let’s break down the key patterns:</p><p><strong>Loading Chart.js.</strong> Odoo ships Chart.js at /web/static/lib/Chart/Chart.js (available since Odoo 17). The loadJS() utility loads it once and caches it. No npm, no CDN, no asset duplication.</p><p><strong>Canvas refs with </strong><strong>useRef().</strong> Instead of document.querySelector(), OWL gives you useRef(). In the template you write &lt;canvas t-ref=&quot;revenueChart&quot;/&gt;, and in JS you access the DOM node via this.revenueChartRef.el. OWL manages the lifecycle for you.</p><p><strong>Lifecycle hooks.</strong> onWillStart runs before the component renders (load data here). onMounted runs after the DOM is ready (render charts here). onWillUnmount handles cleanup (destroy Chart.js instances to prevent memory leaks).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-5sUNbonTi31oBylzExapA.png" /><figcaption>From fetch() to canvas: how a single API call turns into KPI cards and interactive charts.</figcaption></figure><h3>Step 3: The OWL Template — Structure the UI</h3><p>The XML template defines your dashboard’s HTML structure using OWL’s template syntax:</p><p>static/src/xml/dashboard.xml</p><pre>&lt;templates&gt;<br>  &lt;t t-name=&quot;my_module.Dashboard&quot;&gt;<br>    &lt;div class=&quot;dashboard-container&quot;&gt;<br><br>      &lt;h1&gt;My Dashboard&lt;/h1&gt;<br><br>      &lt;!-- Loading spinner --&gt;<br>      &lt;div t-if=&quot;state.loading&quot;<br>           class=&quot;text-center p-5&quot;&gt;<br>        &lt;div class=&quot;spinner-border&quot;/&gt;<br>      &lt;/div&gt;<br><br>      &lt;!-- Dashboard content --&gt;<br>      &lt;div t-else=&quot;&quot;&gt;<br><br>        &lt;!-- KPI Card --&gt;<br>        &lt;div class=&quot;kpi-card&quot;&gt;<br>          &lt;span class=&quot;kpi-label&quot;&gt;Confirmed Orders&lt;/span&gt;<br>          &lt;span class=&quot;kpi-value&quot;&gt;<br>            &lt;t t-esc=&quot;state.kpis.confirmed_orders&quot;/&gt;<br>          &lt;/span&gt;<br>        &lt;/div&gt;<br><br>        &lt;!-- Chart Card --&gt;<br>        &lt;div class=&quot;chart-card&quot;&gt;<br>          &lt;h3&gt;Revenue by Month&lt;/h3&gt;<br>          &lt;canvas t-ref=&quot;revenueChart&quot;/&gt;<br>        &lt;/div&gt;<br><br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/t&gt;<br>&lt;/templates&gt;</pre><p>The important OWL directives here:</p><ul><li>t-if / t-else — conditional rendering (show spinner while loading)</li><li>t-esc — output a value as escaped text</li><li>t-ref — bind a DOM element to a useRef() in JS</li></ul><p>If you have multiple KPIs, you can use t-foreach to loop over them dynamically instead of hard-coding each card.</p><h3>Step 4: Register the Menu</h3><p>The final piece is telling Odoo to show your dashboard as a menu item. You do this with a client action and a menu entry:</p><p><strong>views/menu.xml</strong></p><pre>&lt;record id=&quot;dashboard_action&quot;<br>        model=&quot;ir.actions.client&quot;&gt;<br>    &lt;field name=&quot;name&quot;&gt;My Dashboard&lt;/field&gt;<br>    &lt;field name=&quot;tag&quot;&gt;my_dashboard&lt;/field&gt;<br>&lt;/record&gt;<br><br>&lt;menuitem id=&quot;menu_dashboard&quot;<br>          name=&quot;Dashboard&quot;<br>          parent=&quot;sale.sale_menu_root&quot;<br>          action=&quot;dashboard_action&quot;<br>          sequence=&quot;1&quot;/&gt;</pre><p>The tag field must match the name you used in registry.category(&quot;actions&quot;).add(&quot;my_dashboard&quot;, ...). That&#39;s the glue between the Odoo menu system and your OWL component.</p><h3>Step 5: Wire It Up in __manifest__.py</h3><p>Register your static assets so Odoo bundles them:</p><p>__manifest__.py</p><pre>{<br>    &#39;name&#39;: &#39;My Dashboard&#39;,<br>    &#39;version&#39;: &#39;19.0.1.0.0&#39;,<br>    &#39;depends&#39;: [&#39;base&#39;, &#39;web&#39;, &#39;sale&#39;],<br>    &#39;data&#39;: [<br>        &#39;views/menu.xml&#39;,<br>    ],<br>    &#39;assets&#39;: {<br>        &#39;web.assets_backend&#39;: [<br>            &#39;my_module/static/src/xml/dashboard.xml&#39;,<br>            &#39;my_module/static/src/js/dashboard.js&#39;,<br>        ],<br>    },<br>    &#39;installable&#39;: True,<br>    &#39;application&#39;: True,<br>}</pre><p>Install the module, and your dashboard appears as a menu item under Sales. Click it, and you’ll see your KPI cards and Chart.js charts — all powered by live Odoo data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xfNo8sH4s3MdOQA65_YdYg.png" /><figcaption>The complete file structure — five files is all you need for a working dashboard.</figcaption></figure><h3>Key Takeaways</h3><p>Building a custom dashboard in Odoo comes down to four files:</p><ul><li><strong>A controller</strong> that queries the ORM with search_count() and read_group() and returns JSON.</li><li><strong>An OWL component</strong> that calls the controller, stores data in useState(), and renders Chart.js on &lt;canvas&gt; elements via useRef().</li><li><strong>An XML template</strong> that defines the layout using t-if, t-esc, and t-ref.</li><li><strong>A menu XML</strong> that registers an ir.actions.client pointing to your component&#39;s registry name.</li></ul><p>From here, you can extend this pattern with more charts (doughnut, line, radar — Chart.js supports them all), add data tables, or connect to any Odoo model. The architecture stays the same.</p><p>If this was useful, a clap or a follow helps more than you think. Got questions? Drop a comment — I read every one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dc3d672e4c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Odoo Migration Decoded: 16 → 17 → 18 → 19 — Frontend Revolution: OWL, Services & Modern JS (Part 2)]]></title>
            <link>https://medium.com/@eng.osama1998/odoo-migration-decoded-16-17-18-19-frontend-revolution-owl-services-modern-js-part-2-2d17b0d37ebd?source=rss-26a0731ee4f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d17b0d37ebd</guid>
            <category><![CDATA[owls]]></category>
            <category><![CDATA[odoo-17]]></category>
            <category><![CDATA[odoo-16]]></category>
            <category><![CDATA[odoo-19]]></category>
            <category><![CDATA[odoo18]]></category>
            <dc:creator><![CDATA[Osama Alhalabi]]></dc:creator>
            <pubDate>Sun, 08 Mar 2026 16:22:59 GMT</pubDate>
            <atom:updated>2026-03-08T16:22:59.601Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QffuQpm0GIC_LaudLfrsNA.png" /></figure><p><em>The frontend half of the migration — where your components go from “it works” to “it works differently” and your dates quietly betray you.</em></p><blockquote><em>🔗 Missed Part 1? </em><a href="https://medium.com/@eng.osama1998/odoo-migration-decoded-16-17-18-19-backend-overhaul-orm-views-controllers-part-1-eb6da9fee854"><em>Read Part 1: Backend Overhaul — ORM, Views &amp; Controllers</em></a><em> — covering </em><em>attrs removal, </em><em>name_get() deprecation, ORM changes, views, controllers, and all the Python-side gotchas.</em></blockquote><p>In <a href="https://medium.com/@eng.osama1998/odoo-migration-decoded-16-17-18-19-backend-overhaul-orm-views-controllers-part-1-eb6da9fee854">Part 1</a>, we covered the backend: attrs removal, name_get() deprecation, ORM changes, views, controllers, and all the Python-side gotchas. If you survived that, congratulations — you&#39;ve earned the right to face what many consider the <em>harder</em> half.</p><p><strong><em>Welcome to the JavaScript &amp; OWL migration. </em></strong>🦅</p><p>This is where Odoo’s frontend framework went through its own identity crisis. OWL 1.x became OWL 2.x. Lifecycle methods became hooks. moment.js got replaced by luxon. The widget system was retired in favor of proper components. And somewhere in the middle of it all, YYYY stopped meaning what you thought it meant.</p><p>By the end of this article, you’ll know how to migrate every JS component, field widget, service call, and tour in your codebase — with real before/after code and the pitfalls that catch even senior developers.</p><p><strong><em>Let’s go.</em></strong> 🦅</p><h3>🗺 The OWL Version Map: Quick Orientation</h3><p>Before we get our hands dirty, here’s what you’re dealing with at each version boundary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Hv3MdV17IaDTxk5zkFHhg.png" /><figcaption><em>OWL framework versions across Odoo releases — the big shift happened in 17.0.</em></figcaption></figure><p>The 16 to 17 jump is where 90% of the pain lives. If OWL 1.x was a caterpillar, OWL 2.x is the butterfly — same DNA, completely different shape, and it definitely can’t crawl anymore.</p><h3>🦅 The Great OWL Migration: 1.x to 2.x</h3><h4><strong>The Lifecycle Overhaul</strong></h4><p>This table is the single most important reference for your OWL migration. Print it. Tape it to your monitor. Tattoo it on your forearm if you have to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7EMucAXLbSs47eEotqzHg.png" /><figcaption><em>OWL</em> <em>lifecycle</em> <em>migration</em> <em>cheat</em> <em>sheet</em> <em>— class</em> <em>methods</em> <em>become</em> <em>hook</em> <em>functions</em> <em>called</em> <em>inside</em> <em>setup().</em></figcaption></figure><p>The fundamental shift: in OWL 1.x, lifecycle methods were <em>class methods you overrode</em>. In OWL 2.x, they’re <em>hooks you call inside </em><em>setup()</em>. This isn&#39;t just a syntax change — it&#39;s an architectural philosophy change. Hooks are composable, reusable, and don&#39;t rely on inheritance chains. Think React hooks if you come from that world.</p><h4>Full Component Migration: The DashboardWidget</h4><p>Let’s migrate a real-world component — a dashboard widget that loads data asynchronously, initializes a chart on mount, cleans it up on unmount, and updates it on re-render. This touches every major lifecycle concern.</p><p><strong>Before — OWL 1.x (Odoo 16)</strong></p><pre>/** @odoo-module **/<br>import { Component, useState } from &quot;@odoo/owl&quot;;<br>import { registry } from &quot;@web/core/registry&quot;;<br>import { useService } from &quot;@web/core/utils/hooks&quot;;<br><br>class DashboardWidget extends Component {<br>    static props = [&quot;title&quot;, &quot;modelName&quot;];<br><br>    setup() {<br>        this.state = useState({<br>            data: [],<br>            loading: true,<br>            error: null,<br>        });<br>        this.rpc = useService(&quot;rpc&quot;);<br>    }<br><br>    // OWL 1.x: Async initialization as overridable method<br>    async willStart() {<br>        await this.loadData();<br>    }<br><br>    // OWL 1.x: DOM-ready code as overridable method<br>    mounted() {<br>        this.initializeChart();<br>    }<br><br>    // OWL 1.x: Cleanup as overridable method<br>    willUnmount() {<br>        if (this.chart) {<br>            this.chart.destroy();<br>        }<br>    }<br><br>    // OWL 1.x: Post-render update as overridable method<br>    patched() {<br>        this.updateChart();<br>    }<br><br>    async loadData() {<br>        try {<br>            const result = await this.rpc(&quot;/web/dataset/call_kw&quot;, {<br>                model: this.props.modelName,<br>                method: &quot;search_read&quot;,<br>                args: [[]],<br>                kwargs: { fields: [&quot;name&quot;, &quot;amount&quot;], limit: 10 },<br>            });<br>            this.state.data = result;<br>        } catch (e) {<br>            this.state.error = e.message;<br>        } finally {<br>            this.state.loading = false;<br>        }<br>    }<br><br>    initializeChart() {<br>        const canvas = this.el.querySelector(&quot;.chart-canvas&quot;);<br>        // initialize chart library on the canvas element<br>    }<br><br>    updateChart() {<br>        // update chart with new reactive data<br>    }<br>}<br><br>DashboardWidget.template = &quot;my_module.DashboardWidget&quot;;<br>registry.category(&quot;actions&quot;).add(&quot;dashboard_widget&quot;, DashboardWidget);</pre><p><strong>After — OWL 2.x (Odoo 17+)</strong></p><pre>/** @odoo-module **/<br>import { Component, useState, onWillStart, onMounted, onWillUnmount, onPatched } from &quot;@odoo/owl&quot;;<br>import { registry } from &quot;@web/core/registry&quot;;<br>import { useService } from &quot;@web/core/utils/hooks&quot;;<br><br>class DashboardWidget extends Component {<br>    // OWL 2.x: Props are a validated object schema (not an array)<br>    static props = {<br>        title: { type: String },<br>        modelName: { type: String },<br>    };<br>    static template = &quot;my_module.DashboardWidget&quot;;<br><br>    setup() {<br>        this.state = useState({<br>            data: [],<br>            loading: true,<br>            error: null,<br>        });<br><br>        // OWL 2.x: Use orm service instead of raw rpc<br>        this.orm = useService(&quot;orm&quot;);<br><br>        // Replaces willStart()<br>        onWillStart(async () =&gt; {<br>            await this.loadData();<br>        });<br><br>        // Replaces mounted()<br>        onMounted(() =&gt; {<br>            this.initializeChart();<br>        });<br><br>        // Replaces willUnmount()<br>        onWillUnmount(() =&gt; {<br>            if (this.chart) {<br>                this.chart.destroy();<br>            }<br>        });<br><br>        // Replaces patched()<br>        onPatched(() =&gt; {<br>            this.updateChart();<br>        });<br>    }<br><br>    async loadData() {<br>        try {<br>            // OWL 2.x: orm.searchRead instead of raw RPC<br>            const result = await this.orm.searchRead(<br>                this.props.modelName,<br>                [],<br>                [&quot;name&quot;, &quot;amount&quot;],<br>                { limit: 10 }<br>            );<br>            this.state.data = result;<br>        } catch (e) {<br>            this.state.error = e.message;<br>        } finally {<br>            this.state.loading = false;<br>        }<br>    }<br><br>    initializeChart() {<br>        const canvas = this.el.querySelector(&quot;.chart-canvas&quot;);<br>        // initialize chart on canvas<br>    }<br><br>    updateChart() {<br>        // update chart with new data<br>    }<br>}<br><br>registry.category(&quot;actions&quot;).add(&quot;dashboard_widget&quot;, DashboardWidget);</pre><p>Notice three things beyond the lifecycle changes: template and props are now <strong>static class properties</strong> (not assigned after the class), <strong><em>the </em></strong><strong><em>rpc service is replaced by the </em></strong><strong><em>orm service</em></strong>, and props moved from a simple array to a typed object schema.</p><h3>🧰 Hooks Deep Dive: useState, useRef, useEffect</h3><p>These three hooks are the building blocks of every OWL 2.x component. If you understand them, you understand the framework.</p><h4>useState — Reactive State</h4><pre>import { useState } from &quot;@odoo/owl&quot;;<br><br>setup() {<br>    this.state = useState({<br>        count: 0,<br>        items: [],<br>        selectedId: null,<br>    });<br>}<br><br>// Any mutation triggers a re-render<br>increment() {<br>    this.state.count++;  // component re-renders<br>}<br><br>addItem(item) {<br>    this.state.items.push(item);  // push is reactive in OWL<br>}</pre><p>useState creates a reactive proxy. Mutate any property, and the component re-renders. This works the same in OWL 1.x and 2.x — it&#39;s one of the few things that <em>didn&#39;t</em> break.</p><h4>useRef — DOM Element References</h4><pre>import { useRef, onMounted } from &quot;@odoo/owl&quot;;<br><br>setup() {<br>    this.inputRef = useRef(&quot;myInput&quot;);<br><br>    onMounted(() =&gt; {<br>        // Safe to access .el here -- DOM is ready<br>        if (this.inputRef.el) {<br>            this.inputRef.el.focus();<br>        }<br>    });<br>}</pre><p>In your template: &lt;input t-ref=&quot;myInput&quot; type=&quot;text&quot; /&gt;</p><p>The key change from OWL 1.x: you used to access this.inputRef.el in the mounted() method. Now you access it inside the onMounted callback. Same result, different ceremony. Do <em>not</em> try to access .el outside of a lifecycle hook — it will be null.</p><h4>useEffect — Reactive Side Effects 🔁</h4><pre>import { useState, useEffect, useRef } from &quot;@odoo/owl&quot;;<br><br>setup() {<br>    this.state = useState({ query: &quot;&quot; });<br>    this.resultsRef = useRef(&quot;results&quot;);<br><br>    useEffect(<br>        () =&gt; {<br>            // This runs after renders where &#39;query&#39; changed<br>            const el = this.resultsRef.el;<br>            if (el) el.scrollTop = 0;<br><br>            // Optional: return a cleanup function<br>            return () =&gt; {<br>                // Runs before effect re-executes or on unmount<br>            };<br>        },<br>        // Dependency function: re-run when these values change<br>        () =&gt; [this.state.query]<br>    );<br>}</pre><p>useEffect is OWL 2.x only (Odoo 17+). It&#39;s the equivalent of React&#39;s useEffect — a way to perform side effects that react to specific state changes, with optional cleanup. If you needed patched() but only for <em>certain</em> state changes, this is your tool.</p><h3>🔌 useService: The New Way to Talk to the Backend</h3><p>In OWL 1.x and early Odoo 16 components, you might have used this.rpc(), this.do_action(), or this.displayNotification(). All of those are gone. In OWL 2.x, everything goes through <strong>services</strong>, injected via useService() inside setup().</p><h4>The ORM Service — Your New Best Friend</h4><pre>import { useService } from &quot;@web/core/utils/hooks&quot;;<br><br>setup() {<br>    this.orm = useService(&quot;orm&quot;);<br>}<br><br>// search_read: Fetch records with a domain<br>async fetchOrders() {<br>    const records = await this.orm.searchRead(<br>        &quot;sale.order&quot;,<br>        [[&quot;state&quot;, &quot;=&quot;, &quot;sale&quot;]],<br>        [&quot;name&quot;, &quot;partner_id&quot;, &quot;amount_total&quot;],<br>        { limit: 10, order: &quot;date_order desc&quot; }<br>    );<br>}<br><br>// read: Get specific records by ID<br>async getPartner(id) {<br>    const [record] = await this.orm.read(&quot;res.partner&quot;, [id], [&quot;name&quot;, &quot;email&quot;]);<br>}<br><br>// create: Create a new record<br>async createPartner(vals) {<br>    const id = await this.orm.create(&quot;res.partner&quot;, [vals]);<br>}<br><br>// write: Update existing records<br>async updatePartner(id, vals) {<br>    await this.orm.write(&quot;res.partner&quot;, [id], vals);<br>}<br><br>// unlink: Delete records<br>async deletePartner(id) {<br>    await this.orm.unlink(&quot;res.partner&quot;, [id]);<br>}<br><br>// call: Invoke any model method<br>async confirmOrder(orderId) {<br>    await this.orm.call(&quot;sale.order&quot;, &quot;action_confirm&quot;, [[orderId]], {<br>        context: { send_email: true },<br>    });<br>}</pre><p>This is a massive improvement over raw RPC calls. The orm service handles serialization, error handling, and context propagation for you.</p><h4>The Notification Service</h4><pre>setup() {<br>    this.notification = useService(&quot;notification&quot;);<br>}<br><br>showNotifications() {<br>    // Types: &quot;info&quot;, &quot;success&quot;, &quot;warning&quot;, &quot;danger&quot;<br>    this.notification.add(&quot;Record saved successfully!&quot;, {<br>        type: &quot;success&quot;,<br>        sticky: false,<br>        title: &quot;Success&quot;,<br>    });<br><br>    this.notification.add(&quot;Something needs your attention.&quot;, {<br>        type: &quot;warning&quot;,<br>        sticky: true,  // requires manual dismiss<br>    });<br>}</pre><h4>The Action Service</h4><pre>setup() {<br>    this.actionService = useService(&quot;action&quot;);<br>}<br><br>async openSaleOrder(id) {<br>    await this.actionService.doAction({<br>        type: &quot;ir.actions.act_window&quot;,<br>        res_model: &quot;sale.order&quot;,<br>        res_id: id,<br>        views: [[false, &quot;form&quot;]],<br>        target: &quot;current&quot;,<br>    });<br>}<br><br>async openUrl(url) {<br>    await this.actionService.doAction({<br>        type: &quot;ir.actions.act_url&quot;,<br>        url: url,<br>        target: &quot;new&quot;,<br>    });<br>}<br><br>async openByXmlId(xmlId) {<br>    await this.actionService.doAction(xmlId);<br>}</pre><h4>The Dialog Service</h4><pre>import { useService } from &quot;@web/core/utils/hooks&quot;;<br>import { ConfirmationDialog } from &quot;@web/core/confirmation_dialog/confirmation_dialog&quot;;<br><br>setup() {<br>    this.dialogService = useService(&quot;dialog&quot;);<br>}<br><br>async confirmDelete() {<br>    return new Promise((resolve) =&gt; {<br>        this.dialogService.add(ConfirmationDialog, {<br>            title: &quot;Delete Record&quot;,<br>            body: &quot;Are you sure you want to delete this record?&quot;,<br>            confirm: () =&gt; resolve(true),<br>            cancel: () =&gt; resolve(false),<br>        });<br>    });<br>}</pre><h4>The User Service</h4><pre>setup() {<br>    this.user = useService(&quot;user&quot;);<br>}<br><br>checkUser() {<br>    console.log(this.user.userId);<br>    console.log(this.user.partnerId);<br>    console.log(this.user.isAdmin);<br>}</pre><blockquote><strong>Pro tip:</strong> If you find yourself importing useService(&quot;rpc&quot;) for low-level JSON-RPC calls, ask yourself if useService(&quot;orm&quot;) can do the job instead. The orm service covers 95% of use cases and gives you a much cleaner API.</blockquote><h3>🔄 Legacy Widgets to OWL Components</h3><p>If your Odoo 16 module has widgets built on the old AbstractField / jQuery backbone system, Odoo 17 is the end of the road for them. Here&#39;s the full migration pattern using a ColorPicker field as an example.</p><p><strong>Before — Legacy Widget (Odoo 16)</strong></p><pre>/** @odoo-module legacy=true **/<br>import AbstractField from &quot;web.AbstractField&quot;;<br>import fieldRegistry from &quot;web.field_registry&quot;;<br><br>const ColorPickerField = AbstractField.extend({<br>    template: &quot;my_module.ColorPickerField&quot;,<br><br>    init: function (parent, name, record, options) {<br>        this._super.apply(this, arguments);<br>    },<br><br>    _render: function () {<br>        const value = this.value || &quot;#000000&quot;;<br>        this.$el.html(<br>            `&lt;input type=&quot;color&quot; value=&quot;${value}&quot; class=&quot;o_color_input&quot;/&gt;`<br>        );<br>    },<br><br>    _setValue: function (value) {<br>        return this._super(value);<br>    },<br>});<br><br>fieldRegistry.add(&quot;color_picker&quot;, ColorPickerField);</pre><p><strong>After — OWL Component (Odoo 17+)</strong></p><pre>/** @odoo-module **/<br>import { Component } from &quot;@odoo/owl&quot;;<br>import { registry } from &quot;@web/core/registry&quot;;<br>import { standardFieldProps } from &quot;@web/views/fields/standard_field_props&quot;;<br><br>export class ColorPickerField extends Component {<br>    static template = &quot;my_module.ColorPickerField&quot;;<br>    static props = { ...standardFieldProps };<br>    static supportedTypes = [&quot;char&quot;];<br><br>    get currentColor() {<br>        return this.props.record.data[this.props.name] || &quot;#000000&quot;;<br>    }<br><br>    onColorChange(ev) {<br>        this.props.record.update({ [this.props.name]: ev.target.value });<br>    }<br>}<br><br>registry.category(&quot;fields&quot;).add(&quot;color_picker&quot;, {<br>    component: ColorPickerField,<br>    supportedTypes: [&quot;char&quot;],<br>});</pre><p><strong><em>Key differences to notice:</em></strong></p><ul><li><strong>No more </strong><strong>AbstractField</strong> — you extend plain Component from OWL</li><li><strong>standardFieldProps</strong> gives you record, name, readonly, and other standard props that field widgets need</li><li><strong>Value access</strong> changed from this.value to this.props.record.data[this.props.name]</li><li><strong>Value updates</strong> changed from this._setValue() to this.props.record.update()</li><li><strong>Registration</strong> uses registry.category(&quot;fields&quot;) with a descriptor object, not the old fieldRegistry</li><li><strong>No more </strong><strong>legacy=true</strong> pragma — that compatibility layer is gone in 17+</li></ul><h3>📅 moment.js to luxon: The Date Format Betrayal</h3><p>Odoo 17 replaced moment.js with luxon for all date/time handling on the frontend. The API is different, but the real danger is in the <em>format tokens</em>.</p><h4>The Format Token Table</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oHBcGs6n5MZnWhGv_DqdQ.png" /><figcaption><em>Moment.js</em> <em>to</em> <em>Luxon</em> <em>format</em> <em>token</em> <em>mapping</em> <em>— watch</em> <em>out</em> <em>for</em> <em>the</em> <em>YYYY</em> <em>vs</em> <em>yyyy</em> <em>trap.</em></figcaption></figure><p>That last row is the trap. In luxon, uppercase YYYY means <strong>ISO week-numbering year</strong>, which differs from the calendar year during the first and last days of the year. Your app will show the correct year 362 days a year and the <em>wrong</em> year for about 3 days around New Year&#39;s. Enjoy debugging that on January 2nd. 😅</p><h4>Before and After</h4><pre>// ---- Odoo 16: moment.js ----<br>import moment from &quot;moment&quot;;<br><br>const now = moment();<br>const formatted = now.format(&quot;YYYY-MM-DD HH:mm:ss&quot;);<br>const nextWeek = moment().add(7, &quot;days&quot;);<br>const isBefore = moment(&quot;2024-01-01&quot;).isBefore(moment());<br><br>// ---- Odoo 17+: luxon ----<br>import { DateTime } from &quot;luxon&quot;;<br><br>const now = DateTime.now();<br>const formatted = now.toFormat(&quot;yyyy-MM-dd HH:mm:ss&quot;);   // lowercase yyyy!<br>const nextWeek = now.plus({ days: 7 });<br>const isBefore = DateTime.fromISO(&quot;2024-01-01&quot;) &lt; DateTime.now();</pre><p>Odoo also provides locale-aware helpers:</p><pre>import { formatDate, formatDateTime, parseDate } from &quot;@web/core/l10n/dates&quot;;<br><br>const displayDate = formatDate(myDateTime);         // Uses user&#39;s locale<br>const displayDatetime = formatDateTime(myDateTime);<br>const parsed = parseDate(&quot;01/15/2024&quot;);</pre><h3>🎫 Tour System Changes</h3><p>If you have onboarding tours or browser integration tests, the registration system changed completely in Odoo 17.</p><p><strong>Before (Odoo 16)</strong></p><pre>/** @odoo-module **/<br>import tour from &quot;web_tour.tour&quot;;<br><br>tour.register(&quot;my_custom_tour&quot;, {<br>    url: &quot;/web&quot;,<br>    test: true,<br>}, [<br>    {<br>        trigger: &quot;.o_main_navbar&quot;,<br>        content: &quot;Welcome to the tour&quot;,<br>        position: &quot;bottom&quot;,<br>    },<br>    {<br>        trigger: &quot;.o_list_button_add&quot;,<br>        content: &quot;Create a new record&quot;,<br>        position: &quot;bottom&quot;,<br>    },<br>]);</pre><p><strong>After (Odoo 17+)</strong></p><pre>/** @odoo-module **/<br>import { registry } from &quot;@web/core/registry&quot;;<br><br>registry.category(&quot;web_tour.tours&quot;).add(&quot;my_custom_tour&quot;, {<br>    url: &quot;/web&quot;,<br>    test: true,<br>    steps: () =&gt; [<br>        {<br>            trigger: &quot;.o_main_navbar&quot;,<br>            content: &quot;Welcome to the tour&quot;,<br>            position: &quot;bottom&quot;,<br>        },<br>        {<br>            trigger: &quot;.o_list_button_add&quot;,<br>            content: &quot;Create a new record&quot;,<br>            run: &quot;click&quot;,<br>        },<br>    ],<br>});</pre><p>Two things changed: tours now go through the standard registry.category(&quot;web_tour.tours&quot;) system (no more special tour import), and steps is now a <strong>function</strong> that returns the steps array. The run property also became more explicit — &quot;click&quot;, &quot;edit Value&quot;, &quot;fill Value&quot; instead of implicit click behavior.</p><h3>📚 Component Registration: The Registry Categories</h3><p>The registry is how Odoo’s frontend discovers your components. Here are all the categories you need to know, with registration examples for each.</p><h4>Fields</h4><pre>registry.category(&quot;fields&quot;).add(&quot;my_custom_field&quot;, {<br>    component: MyCustomFieldComponent,<br>    supportedTypes: [&quot;char&quot;, &quot;text&quot;],<br>    extractProps: ({ attrs }) =&gt; ({<br>        placeholder: attrs.placeholder,<br>    }),<br>});</pre><h4>Views</h4><pre>registry.category(&quot;views&quot;).add(&quot;my_custom_view&quot;, {<br>    type: &quot;my_custom_view&quot;,<br>    display_name: &quot;My Custom View&quot;,<br>    icon: &quot;fa-list&quot;,<br>    multiRecord: true,<br>    Controller: MyViewController,<br>    Renderer: MyViewRenderer,<br>});</pre><h4>Actions (Client Actions)</h4><pre>registry.category(&quot;actions&quot;).add(&quot;my_client_action&quot;, MyActionComponent);</pre><h4>Services</h4><pre>registry.category(&quot;services&quot;).add(&quot;my_service&quot;, {<br>    dependencies: [&quot;orm&quot;, &quot;notification&quot;],<br>    start(env, { orm, notification }) {<br>        return {<br>            async doSomething(id) {<br>                const result = await orm.read(&quot;res.partner&quot;, [id], [&quot;name&quot;]);<br>                notification.add(`Loaded: ${result[0].name}`, { type: &quot;success&quot; });<br>                return result;<br>            },<br>        };<br>    },<br>});</pre><h4>Systray Items</h4><pre>registry.category(&quot;systray&quot;).add(&quot;my_systray_item&quot;, {<br>    Component: MySystrayComponent,<br>    sequence: 50,<br>});</pre><h4>User Menu Items</h4><pre>registry.category(&quot;user_menuitems&quot;).add(&quot;my_menu_item&quot;, () =&gt; ({<br>    type: &quot;item&quot;,<br>    id: &quot;my_item&quot;,<br>    description: &quot;My Custom Item&quot;,<br>    callback: () =&gt; console.log(&quot;clicked&quot;),<br>    sequence: 30,<br>}));</pre><p>The registry API itself is stable across Odoo 16–19. What changed is <em>what you register</em> — OWL 2.x components with static properties instead of legacy widgets.</p><h3>📨 Props Validation and Parent-Child Communication</h3><h4>Props: From Arrays to Schemas</h4><p><strong>OWL 1.x (Odoo 16) — Simple array syntax</strong></p><pre>static props = [&quot;title&quot;, &quot;recordId&quot;, &quot;*&quot;];<br>// &quot;*&quot; means &quot;accept any additional props&quot;</pre><p><strong>OWL 2.x (Odoo 17+) — Full object schema with types, defaults, and validation</strong></p><pre>static props = {<br>    title: { type: String },<br>    limit: { type: Number, optional: true },<br>    readonly: { type: Boolean, optional: true },<br>    size: {<br>        type: String,<br>        validate: (v) =&gt; [&quot;sm&quot;, &quot;md&quot;, &quot;lg&quot;].includes(v),<br>        optional: true,<br>    },<br>    record: {<br>        type: Object,<br>        shape: { id: Number, name: String },<br>    },<br>    items: { type: Array, element: Object, optional: true },<br>    onClose: { type: Function, optional: true },<br>    &quot;*&quot;: true,  // wildcard for remaining props<br>};<br><br>static defaultProps = {<br>    limit: 10,<br>    readonly: false,<br>    size: &quot;md&quot;,<br>};</pre><p>This is a big upgrade for maintainability. You get runtime type checking, optional markers, custom validators, and default values. Use it.</p><h4>Parent-Child Communication: The Callback Pattern</h4><p>OWL 2.x uses callback props for child-to-parent communication — no event bus, no trigger_up. Clean and explicit.</p><pre>// ---- Child Component ----<br>class ChildComponent extends Component {<br>    static props = {<br>        value: { type: Number },<br>        onValueChange: { type: Function },<br>    };<br>    static template = &quot;my_module.ChildComponent&quot;;<br><br>    increment() {<br>        this.props.onValueChange(this.props.value + 1);<br>    }<br>}<br><br>// ---- Parent Component ----<br>class ParentComponent extends Component {<br>    static components = { ChildComponent };<br>    static template = &quot;my_module.ParentComponent&quot;;<br><br>    setup() {<br>        this.state = useState({ count: 0 });<br>    }<br><br>    updateCount(newValue) {<br>        this.state.count = newValue;<br>    }<br>}</pre><p>Parent template:</p><pre>&lt;div&gt;<br>    &lt;ChildComponent value=&quot;state.count&quot; onValueChange.bind=&quot;updateCount&quot;/&gt;<br>&lt;/div&gt;</pre><p>The .bind in the template is critical — it binds the callback to the parent&#39;s this context. Without it, this inside updateCount would be wrong.</p><h3>🔒 CSP and Asset Bundling: No More Inline Scripts</h3><p>Starting in Odoo 17 and tightened further in 18 and 19, Odoo enforces <strong>Content Security Policy</strong> headers that block inline JavaScript. If your module injects &lt;script&gt; tags dynamically or loads external CDN scripts at runtime, it will break silently in production.</p><h4>What breaks:</h4><pre>// This will be blocked by CSP in Odoo 18+<br>const script = document.createElement(&quot;script&quot;);<br>script.src = &quot;https://cdn.example.com/chart-library.js&quot;;<br>document.head.appendChild(script);</pre><h4>What to do instead:</h4><p>Vendor the library into your module’s static/lib/ folder and declare it in __manifest__.py:</p><pre>&quot;assets&quot;: {<br>    &quot;web.assets_backend&quot;: [<br>        &quot;my_module/static/lib/chart-library/chart-library.min.js&quot;,<br>        &quot;my_module/static/src/js/my_component.js&quot;,<br>        &quot;my_module/static/src/xml/my_templates.xml&quot;,<br>    ],<br>},</pre><p>Also relevant: the @odoo-module pragma. Every JS file must have /** @odoo-module **/ as its first line. In Odoo 16, you could use /** @odoo-module alias=my_module.legacy_name **/ for backward compatibility. In Odoo 17+, the alias option is no longer needed — drop it.</p><h3>✅ Migration Checklist: JavaScript &amp; OWL (16 to 17 to 18 to 19)</h3><h4>16 to 17 (The Big One)</h4><ol><li><strong>Migrate ALL OWL 1.x lifecycle methods to hooks in </strong><strong>setup():</strong></li></ol><ul><li>willStart() to onWillStart(async () =&gt; { ... })</li><li>mounted() to onMounted(() =&gt; { ... })</li><li>willUnmount() to onWillUnmount(() =&gt; { ... })</li><li>patched() to onPatched(() =&gt; { ... })</li><li>willUpdateProps() to onWillUpdateProps(() =&gt; { ... })</li></ul><p>2. Move template and props to <strong>static</strong> class properties</p><p>3. Update static props from array syntax to object schema</p><p>4. Add static defaultProps where needed</p><p>5. Replace this.rpc() / raw RPC calls with useService(&quot;orm&quot;)</p><p>6. Replace this.do_action() with useService(&quot;action&quot;).doAction()</p><p>7. Replace this.displayNotification() with useService(&quot;notification&quot;).add()</p><p>8. Replace ALL moment.js usage with luxon (watch for YYYY vs yyyy)</p><p>9. Migrate legacy AbstractField widgets to OWL Components with standardFieldProps</p><p>10. Remove legacy=true from @odoo-module pragmas</p><p>11. Update tour definitions to registry.category(&quot;web_tour.tours&quot;)</p><p>12. Update tour steps to use explicit run property</p><p>13. Replace web.field_registry with registry.category(&quot;fields&quot;)</p><h4>17 to 18</h4><ul><li>Audit all field component extractProps functions (API stabilized)</li><li>Update custom dialog components to use the dialog service pattern</li><li>Review useEffect() dependency arrays for correctness</li><li>Remove any inline &lt;script&gt; injection — use asset bundles instead</li><li>Vendor third-party JS libraries into static/lib/</li><li>Test all frontend components for CSP errors in browser console</li></ul><h4>18 to 19</h4><ul><li>Check for any OWL 2.x API refinements in Odoo 19 release notes</li><li>Verify all registry categories still exist</li><li>Update any deprecated service APIs</li><li>Test all custom OWL components in Odoo 19 runtime</li></ul><h3>💥 The 5 Common Pitfalls That Will Waste Your Afternoon</h3><h4>Pitfall 1: The Static Property Oversight 🦅</h4><p>Putting template or props as <em>instance</em> properties instead of <em>static</em> class properties. OWL 2.x silently ignores instance-level declarations.</p><pre>// WRONG -- OWL will NOT find these<br>class MyWidget extends Component {<br>    template = &quot;my_module.MyWidget&quot;;<br>    props = { label: String };<br>}<br><br>// RIGHT -- static is required<br>class MyWidget extends Component {<br>    static template = &quot;my_module.MyWidget&quot;;<br>    static props = { label: { type: String } };<br>}</pre><p>This one is especially frustrating because there’s no error message. Your component just renders nothing, and you stare at the screen wondering what you did to deserve this.</p><h4>Pitfall 2: this.el Outside onMounted</h4><p>Accessing this.el in setup() or anywhere before the component has mounted.</p><pre>// WRONG -- this.el is null during setup<br>setup() {<br>    const chart = this.el.querySelector(&quot;.chart&quot;); // TypeError: null<br>}<br><br>// RIGHT -- access this.el only inside onMounted or onPatched<br>setup() {<br>    onMounted(() =&gt; {<br>        const chart = this.el.querySelector(&quot;.chart&quot;); // Safe<br>    });<br>}</pre><p>If you need DOM access during the component’s life, always wrap it in onMounted, onPatched, or access via useRef.</p><h4>Pitfall 3: willStart() as a Method Override</h4><p>Writing willStart() as a class method and expecting it to be called. In OWL 2.x, it won&#39;t be.</p><pre>// WRONG -- this method is never called in OWL 2.x<br>class MyComponent extends Component {<br>    async willStart() {<br>        await this.loadData();<br>    }<br>}<br><br>// RIGHT -- use the hook inside setup()<br>class MyComponent extends Component {<br>    setup() {<br>        onWillStart(async () =&gt; {<br>            await this.loadData();<br>        });<br>    }<br>}</pre><p>This is the single most common OWL migration bug we see. The component mounts, but your data never loads. No error, no warning — just an empty component staring back at you.</p><h4>Pitfall 4: this.rpc() Is Gone</h4><p>Calling this.rpc() directly on the component. That method doesn&#39;t exist in OWL 2.x.</p><pre>// WRONG -- rpc is not a method on Component<br>async loadData() {<br>    const result = await this.rpc(&quot;/web/dataset/call_kw&quot;, { ... }); // Error!<br>}<br><br>// RIGHT -- use the orm service<br>setup() {<br>    this.orm = useService(&quot;orm&quot;);<br>}<br>async loadData() {<br>    const result = await this.orm.searchRead(&quot;my.model&quot;, [], [&quot;name&quot;]);<br>}</pre><h4>Pitfall 5: The Date Format Betrayal (YYYY vs yyyy)</h4><p>Swapping moment.js for luxon and keeping the uppercase YYYY format token.</p><pre>// WRONG -- YYYY means ISO week-year in luxon<br>DateTime.now().toFormat(&quot;YYYY-MM-DD&quot;)<br>// Returns &quot;2026&quot; most of the time... but &quot;2027&quot; on Dec 31 if that<br>// week belongs to next year&#39;s ISO week calendar. Fun!<br><br>// RIGHT -- lowercase yyyy means calendar year<br>DateTime.now().toFormat(&quot;yyyy-MM-dd&quot;)</pre><p>This bug ships to production because it passes all your tests. It only manifests around New Year’s when the ISO week-year diverges from the calendar year. By then, your client has already sent invoices with the wrong date. Ask me how I know.</p><h3>👀 TL;DR — For the Skimmers (I See You)</h3><ol><li><strong>OWL 1.x lifecycle methods are dead.</strong> Use hooks (onWillStart, onMounted, onPatched, etc.) inside setup().</li><li><strong>template and </strong><strong>props must be </strong><strong>static.</strong> Instance properties are silently ignored.</li><li><strong>this.rpc() is gone.</strong> Use useService(&quot;orm&quot;) for model operations.</li><li><strong>moment.js is gone.</strong> Use luxon. Lowercase yyyy = calendar year. Uppercase YYYY = ISO week-year (the trap).</li><li><strong>Legacy widgets are gone.</strong> Migrate AbstractField.extend() to OWL Component with standardFieldProps.</li><li><strong>Tours use the registry now.</strong> web_tour.tour import replaced by registry.category(&quot;web_tour.tours&quot;).</li><li><strong>Services for everything.</strong> Notifications, actions, dialogs, user info, and ORM all go through useService().</li><li><strong>Props validation upgraded.</strong> Array syntax to object schemas with types, optional markers, validators, and defaults.</li><li><strong>Parent-child communication</strong> uses callback props with .bind, not event buses.</li><li><strong>CSP is real.</strong> No inline scripts. Vendor your libraries. Use asset bundles.</li></ol><p>The 16 to 17 JavaScript migration is the hardest part of the entire Odoo upgrade path. Plan twice the time you think you need. Then add a buffer. You’ll use it.</p><p>That wraps up the frontend side of the Odoo migration journey. Combined with <a href="https://medium.com/@eng.osama1998/odoo-migration-decoded-16-17-18-19-backend-overhaul-orm-views-controllers-part-1-eb6da9fee854"><strong><em>Part 1</em></strong></a>, you now have a complete reference for migrating Odoo modules from 16 all the way to 19.</p><p>— <a href="https://www.linkedin.com/in/osama-alhalabi-56b4181a8/"><strong>Osama Alhalabi</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d17b0d37ebd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Odoo Migration Decoded: 16 → 17 → 18 → 19 — Backend Overhaul: ORM, Views & Controllers (Part 1)]]></title>
            <link>https://medium.com/@eng.osama1998/odoo-migration-decoded-16-17-18-19-backend-overhaul-orm-views-controllers-part-1-eb6da9fee854?source=rss-26a0731ee4f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb6da9fee854</guid>
            <category><![CDATA[odoo-migration]]></category>
            <category><![CDATA[odoo18]]></category>
            <category><![CDATA[odoo-16]]></category>
            <category><![CDATA[odoo-19]]></category>
            <category><![CDATA[odoo-17]]></category>
            <dc:creator><![CDATA[Osama Alhalabi]]></dc:creator>
            <pubDate>Wed, 04 Mar 2026 18:35:47 GMT</pubDate>
            <atom:updated>2026-03-04T18:35:47.026Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gU-8hkmCk6Zt5_Y8jkNHsg.png" /></figure><p><em>Everything that changed on the backend, everything that broke in your XML, and exactly how to fix it — with code you can copy into your module today.</em></p><p>It’s Monday morning. Your client sends you a Slack message: <strong>“Hey, we’re upgrading to Odoo 19. How long will it take?”</strong> Your coffee goes cold. Your soul briefly exits your body. You’ve heard the stories — the attrs that stopped working, the name_get that got <em>gone</em>, the XML views that looked right but weren&#39;t.</p><p>This is Part 1 of a two-part guide covering everything <em>except</em> JavaScript and OWL (that’s Part 2). Here we tackle the Python, XML, SCSS, and server-side changes that will break your module — and exactly how to fix them.</p><h3>🗺️ The Version Map: What Changed When</h3><p>Before we dive in, here’s the 30,000-foot view. Think of each Odoo version like a movie sequel — same universe, different rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8cqgGEpM4u9zrAXyRHLOhg.png" /><figcaption>Odoo 16–19 at a Glance: Releases, Breaking Changes &amp; Vibes</figcaption></figure><blockquote><strong>Pro tip:</strong><em> The 16 to 17 jump is the most painful by far. If you survive that, 17 to 18 to 19 is mostly incremental polish. Think of 16 to 17 as moving from an apartment to a house — same city, completely different furniture arrangement.</em></blockquote><h4>💥 The Big Breaking Changes (16 to 17)</h4><p>These two changes (plus OWL, covered in Part 2) are responsible for roughly 80% of migration headaches. Address them first.</p><p><strong>Goodbye </strong><strong>attrs, Hello Inline Expressions</strong></p><p>attrs was the XML mechanism for dynamically showing, hiding, or making fields required based on conditions. It looked like a Python dict embedded in your XML -- which, honestly, was always a bit odd. Odoo 17 ripped it out entirely and replaced it with direct inline attribute expressions. Cleaner, more readable, and absolutely guaranteed to break your module if you don&#39;t update it.</p><p>Think of attrs like an old universal remote with one overloaded button. The new system gives each function its own dedicated button.</p><p><strong>Before (Odoo 16)</strong></p><pre>&lt;field name=&quot;partner_id&quot;<br>       attrs=&quot;{&#39;invisible&#39;: [(&#39;state&#39;, &#39;=&#39;, &#39;draft&#39;)],<br>               &#39;readonly&#39;:  [(&#39;state&#39;, &#39;not in&#39;, [&#39;draft&#39;, &#39;sent&#39;])],<br>               &#39;required&#39;:  [(&#39;state&#39;, &#39;=&#39;, &#39;confirmed&#39;)]}&quot; /&gt;<br><br>&lt;button name=&quot;action_confirm&quot;<br>        states=&quot;draft&quot;<br>        type=&quot;object&quot;<br>        string=&quot;Confirm&quot; /&gt;</pre><p><strong>After (Odoo 17+)</strong></p><pre>&lt;field name=&quot;partner_id&quot;<br>       invisible=&quot;state == &#39;draft&#39;&quot;<br>       readonly=&quot;state not in (&#39;draft&#39;, &#39;sent&#39;)&quot;<br>       required=&quot;state == &#39;confirmed&#39;&quot; /&gt;<br><br>&lt;!-- states attribute is GONE -- use invisible instead --&gt;<br>&lt;button name=&quot;action_confirm&quot;<br>        invisible=&quot;state != &#39;draft&#39;&quot;<br>        type=&quot;object&quot;<br>        string=&quot;Confirm&quot; /&gt;</pre><h4>Complete Expression Syntax Reference</h4><p>Here’s every pattern you’ll encounter when translating attrs domains to inline expressions:</p><pre>&lt;!-- Simple equality --&gt;<br>&lt;!-- Old: attrs=&quot;{&#39;invisible&#39;: [(&#39;state&#39;, &#39;=&#39;, &#39;draft&#39;)]}&quot; --&gt;<br>&lt;field name=&quot;x&quot; invisible=&quot;state == &#39;draft&#39;&quot;/&gt;<br><br>&lt;!-- NOT equal --&gt;<br>&lt;!-- Old: attrs=&quot;{&#39;invisible&#39;: [(&#39;state&#39;, &#39;!=&#39;, &#39;sale&#39;)]}&quot; --&gt;<br>&lt;field name=&quot;x&quot; invisible=&quot;state != &#39;sale&#39;&quot;/&gt;<br><br>&lt;!-- IN operator --&gt;<br>&lt;!-- Old: attrs=&quot;{&#39;invisible&#39;: [(&#39;state&#39;, &#39;in&#39;, [&#39;draft&#39;, &#39;cancel&#39;])]}&quot; --&gt;<br>&lt;field name=&quot;x&quot; invisible=&quot;state in (&#39;draft&#39;, &#39;cancel&#39;)&quot;/&gt;<br><br>&lt;!-- NOT IN operator --&gt;<br>&lt;!-- Old: attrs=&quot;{&#39;invisible&#39;: [(&#39;state&#39;, &#39;not in&#39;, [&#39;sale&#39;, &#39;done&#39;])]}&quot; --&gt;<br>&lt;field name=&quot;x&quot; invisible=&quot;state not in (&#39;sale&#39;, &#39;done&#39;)&quot;/&gt;<br><br>&lt;!-- Boolean field check --&gt;<br>&lt;!-- Old: attrs=&quot;{&#39;invisible&#39;: [(&#39;active&#39;, &#39;=&#39;, False)]}&quot; --&gt;<br>&lt;field name=&quot;x&quot; invisible=&quot;not active&quot;/&gt;<br><br>&lt;!-- AND condition (list of conditions in old attrs was AND by default) --&gt;<br>&lt;!-- Old: attrs=&quot;{&#39;invisible&#39;: [(&#39;state&#39;, &#39;=&#39;, &#39;draft&#39;), (&#39;type&#39;, &#39;=&#39;, &#39;service&#39;)]}&quot; --&gt;<br>&lt;field name=&quot;x&quot; invisible=&quot;state == &#39;draft&#39; and type == &#39;service&#39;&quot;/&gt;<br><br>&lt;!-- OR condition (old attrs used &#39;|&#39; prefix) --&gt;<br>&lt;!-- Old: attrs=&quot;{&#39;invisible&#39;: [&#39;|&#39;, (&#39;type&#39;, &#39;=&#39;, &#39;service&#39;), (&#39;active&#39;, &#39;=&#39;, False)]}&quot; --&gt;<br>&lt;field name=&quot;x&quot; invisible=&quot;type == &#39;service&#39; or not active&quot;/&gt;<br><br>&lt;!-- Numeric comparison --&gt;<br>&lt;!-- Old: attrs=&quot;{&#39;readonly&#39;: [(&#39;qty_invoiced&#39;, &#39;&gt;&#39;, 0)]}&quot; --&gt;<br>&lt;field name=&quot;x&quot; readonly=&quot;qty_invoiced &gt; 0&quot;/&gt;<br><br>&lt;!-- Nested conditions --&gt;<br>&lt;field name=&quot;x&quot; invisible=&quot;(state == &#39;draft&#39; and not partner_id) or state == &#39;cancel&#39;&quot;/&gt;<br><br>&lt;!-- column_invisible with parent.field syntax (inside O2M sub-views) --&gt;<br>&lt;field name=&quot;qty_delivered&quot;<br>       column_invisible=&quot;parent.state == &#39;draft&#39;&quot;/&gt;</pre><p>The states attribute was shorthand for visibility based on a field named state. It&#39;s fully gone in 17+:</p><pre>&lt;!-- Odoo 16 --&gt;<br>&lt;field name=&quot;partner_id&quot; states=&quot;draft,sent&quot;/&gt;<br>&lt;!-- meant: visible only when state in (&#39;draft&#39;, &#39;sent&#39;) --&gt;<br><br>&lt;!-- Odoo 17+ --&gt;<br>&lt;field name=&quot;partner_id&quot; invisible=&quot;state not in (&#39;draft&#39;, &#39;sent&#39;)&quot;/&gt;</pre><blockquote><strong>Note<em>:</em></strong><em> These inline expressions evaluate in a JavaScript context. No imports, no function calls — just simple comparisons and logical operators. If your </em><em>attrs had really complex nested logic, you may need a helper Boolean computed field on the model side.</em></blockquote><p><strong>name_get() to </strong><strong>_compute_display_name: The Identity Crisis</strong></p><p>name_get() was the OG method for controlling how a record&#39;s name appears in dropdowns, breadcrumbs, and anywhere Odoo needs a human-readable label. In 17, it was deprecated in favor of a proper computed field. In 18+, the old method is essentially dead. Your module will silently return wrong names or throw warnings — neither is fun to debug in production.</p><p><strong>Before (Odoo 16)</strong></p><pre>class ProductVariant(models.Model):<br>    _name = &#39;product.variant&#39;<br><br>    name = fields.Char(required=True)<br>    color = fields.Char()<br>    size = fields.Char()<br><br>    def name_get(self):<br>        result = []<br>        for record in self:<br>            name = record.name<br>            if record.color:<br>                name = f&quot;{name} [{record.color}]&quot;<br>            if record.size:<br>                name = f&quot;{name} - {record.size}&quot;<br>            result.append((record.id, name))<br>        return result</pre><p>After (Odoo 17+)</p><pre>class ProductVariant(models.Model):<br>    _name = &#39;product.variant&#39;<br><br>    name = fields.Char(required=True)<br>    color = fields.Char()<br>    size = fields.Char()<br><br>    def _compute_display_name(self):<br>        for record in self:<br>            name = record.name<br>            if record.color:<br>                name = f&quot;{name} [{record.color}]&quot;<br>            if record.size:<br>                name = f&quot;{name} - {record.size}&quot;<br>            record.display_name = name</pre><h4>The Inheritance Case</h4><p>If you were extending an existing model’s name_get via super(), the pattern changes too:</p><pre># Odoo 16<br>class SaleOrder(models.Model):<br>    _inherit = &#39;sale.order&#39;<br><br>    def name_get(self):<br>        result = super().name_get()<br>        return [(rec_id, f&quot;{name} (Custom)&quot;) for rec_id, name in result]<br><br># Odoo 17+<br>class SaleOrder(models.Model):<br>    _inherit = &#39;sale.order&#39;<br><br>    def _compute_display_name(self):<br>        super()._compute_display_name()<br>        for record in self:<br>            record.display_name = f&quot;{record.display_name} (Custom)&quot;</pre><p><strong>Why this is actually an upgrade:</strong> Because display_name is now a proper computed field, you can set store=True and use it in search filters and ORDER BY clauses. That&#39;s a genuine improvement, not just a rename.</p><h3>❤️ ORM Upgrades You’ll Actually Love</h3><p>Not everything about migration is suffering. Some of these ORM changes are genuinely great once you get used to them.</p><h4>Command Objects: Goodbye Magic Numbers 👋</h4><p>If you’ve ever written (0, 0, {...}) to create a One2many record and had to Google what those zeros mean, you&#39;re in good company. Odoo 17+ makes Command objects the official pattern. Here&#39;s the full reference:</p><pre>from odoo import Command<br><br># CREATE a new related record<br># Old: (0, 0, {&#39;name&#39;: &#39;New Line&#39;, &#39;qty&#39;: 1})<br>Command.create({&#39;name&#39;: &#39;New Line&#39;, &#39;qty&#39;: 1})<br><br># UPDATE an existing related record<br># Old: (1, record_id, {&#39;qty&#39;: 2})<br>Command.update(record_id, {&#39;qty&#39;: 2})<br><br># DELETE a record (removes from DB entirely)<br># Old: (2, record_id, 0)<br>Command.delete(record_id)<br><br># UNLINK (disconnect without deleting from DB)<br># Old: (3, record_id, 0)<br>Command.unlink(record_id)<br><br># LINK an existing record<br># Old: (4, record_id, 0)<br>Command.link(record_id)<br><br># CLEAR all records (unlink all)<br># Old: (5, 0, 0)<br>Command.clear()<br><br># SET (replace entire list with these IDs)<br># Old: (6, 0, [id1, id2, id3])<br>Command.set([id1, id2, id3])</pre><p>Real-world before and after:</p><pre># Odoo 16<br>order = self.env[&#39;sale.order&#39;].create({<br>    &#39;partner_id&#39;: partner.id,<br>    &#39;order_line&#39;: [<br>        (0, 0, {&#39;product_id&#39;: prod1.id, &#39;product_uom_qty&#39;: 2}),<br>        (1, line.id, {&#39;product_uom_qty&#39;: 5}),<br>        (2, old_line.id, 0),<br>    ],<br>    &#39;tag_ids&#39;: [(6, 0, [tag1.id, tag2.id])],<br>})<br><br># Odoo 17+<br>from odoo import Command<br><br>order = self.env[&#39;sale.order&#39;].create({<br>    &#39;partner_id&#39;: partner.id,<br>    &#39;order_line&#39;: [<br>        Command.create({&#39;product_id&#39;: prod1.id, &#39;product_uom_qty&#39;: 2}),<br>        Command.update(line.id, {&#39;product_uom_qty&#39;: 5}),<br>        Command.delete(old_line.id),<br>    ],<br>    &#39;tag_ids&#39;: [Command.set([tag1.id, tag2.id])],<br>})</pre><p>Self-documenting, IDE-autocomplete-friendly, and far less likely to cause “wait, was it (0, 0, {}) or (0, False, {})?&quot; debates in code review.</p><blockquote><strong><em>Import note:</em></strong><em> It’s </em><em>from odoo import Command, not </em><em>from odoo.fields import Command. This trips people up.</em></blockquote><p><strong>The New </strong><strong>_read_group() API</strong></p><p>The old read_group() returned a list of dictionaries. The new _read_group() returns tuples with actual record objects for relational fields. That means no more group[&quot;account_id&quot;][1] to get the account name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*omOZgb9NjYf7x-N3KN3yrw.png" /><figcaption><em>read_group()</em> <em>vs</em> <em>_read_group():</em> <em>What</em> <em>Changed</em> <em>in</em> <em>Odoo</em> <em>17+</em></figcaption></figure><pre># Odoo 16<br>results = self.env[&#39;account.move.line&#39;].read_group(<br>    domain=[(&#39;move_id.state&#39;, &#39;=&#39;, &#39;posted&#39;)],<br>    fields=[&#39;account_id&#39;, &#39;debit:sum&#39;, &#39;credit:sum&#39;],<br>    groupby=[&#39;account_id&#39;],<br>)<br>for group in results:<br>    print(group[&#39;account_id&#39;][1], group[&#39;debit&#39;], group[&#39;credit&#39;])<br><br># Odoo 17+<br>results = self.env[&#39;account.move.line&#39;]._read_group(<br>    domain=[(&#39;move_id.state&#39;, &#39;=&#39;, &#39;posted&#39;)],<br>    groupby=[&#39;account_id&#39;],<br>    aggregates=[&#39;debit:sum&#39;, &#39;credit:sum&#39;],<br>)<br>for account, debit_sum, credit_sum in results:<br>    print(account.name, debit_sum, credit_sum)  # Actual records!</pre><p><strong>Markup() for HTML Safety</strong></p><p>Raw HTML string concatenation is officially a security problem in Odoo 17+. All HTML content in Python must use markupsafe.Markup to prevent XSS vulnerabilities.</p><pre># Odoo 16 -- common but unsafe<br>def _get_description(self):<br>    return &quot;&lt;p&gt;Hello &lt;b&gt;&quot; + self.name + &quot;&lt;/b&gt;&lt;/p&gt;&quot;  # XSS risk<br><br># Odoo 17+ -- Markup required<br>from markupsafe import Markup, escape<br><br>def _get_description(self):<br>    return Markup(&quot;&lt;p&gt;Hello &lt;b&gt;%s&lt;/b&gt;&lt;/p&gt;&quot;) % escape(self.name)# Odoo 17+ -- Markup required<br>from markupsafe import Markup, escape</pre><p>This extends to message_post in the chatter:</p><pre># Odoo 16<br>self.message_post(body=&quot;&lt;p&gt;Invoice &quot; + inv.name + &quot; confirmed&lt;/p&gt;&quot;)<br><br># Odoo 17+<br>from markupsafe import Markup, escape<br><br>self.message_post(<br>    body=Markup(&quot;&lt;p&gt;Invoice &lt;b&gt;%s&lt;/b&gt; confirmed&lt;/p&gt;&quot;) % escape(inv.name)<br>)</pre><p><strong>flush() and </strong><strong>invalidate_cache() Replacements</strong></p><p>The old blanket methods are replaced with more granular versions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzympVi4iQJhQfZUxlf0PQ.png" /><figcaption><em>Odoo</em> <em>17</em> <em>ORM</em> <em>Renames:</em> <em>Cache</em> <em>Invalidation</em> <em>&amp;</em> <em>Flush</em> <em>Methods</em></figcaption></figure><pre># Odoo 16<br>self.env[&#39;res.partner&#39;].invalidate_cache([&#39;name&#39;, &#39;email&#39;])<br>self.env[&#39;res.partner&#39;].flush()<br><br># Odoo 17+<br>records.invalidate_recordset([&#39;name&#39;, &#39;email&#39;])<br>records.flush_recordset([&#39;name&#39;, &#39;email&#39;])<br># Or at model level:<br>self.env[&#39;res.partner&#39;].invalidate_model([&#39;name&#39;])<br>self.env[&#39;res.partner&#39;].flush_model([&#39;name&#39;])</pre><h3>🎨 Views: The Great XML Makeover</h3><p>If the ORM changes are the plumbing renovation, the view changes are the interior redesign. Same house, new fixtures everywhere.</p><p><strong>&lt;tree&gt; to </strong><strong>&lt;list&gt;</strong></p><p>The most cosmetic but also most-searched-on-Google rename: tree views are now list views.</p><pre>&lt;!-- Odoo 16 --&gt;<br>&lt;tree string=&quot;Sale Orders&quot; decoration-danger=&quot;state == &#39;cancel&#39;&quot;&gt;<br>    &lt;field name=&quot;name&quot;/&gt;<br>    &lt;field name=&quot;state&quot;/&gt;<br>&lt;/tree&gt;<br><br>&lt;!-- Odoo 17+ --&gt;<br>&lt;list string=&quot;Sale Orders&quot; decoration-danger=&quot;state == &#39;cancel&#39;&quot;&gt;<br>    &lt;field name=&quot;name&quot;/&gt;<br>    &lt;field name=&quot;state&quot;/&gt;<br>&lt;/list&gt;</pre><p>Don’t forget inherited views — your XPath targets need updating too:</p><pre>&lt;!-- Odoo 16 --&gt;<br>&lt;xpath expr=&quot;//field[@name=&#39;order_line&#39;]/tree/field[@name=&#39;price_unit&#39;]&quot; position=&quot;after&quot;&gt;<br><br>&lt;!-- Odoo 17+ --&gt;<br>&lt;xpath expr=&quot;//field[@name=&#39;order_line&#39;]/list/field[@name=&#39;price_unit&#39;]&quot; position=&quot;after&quot;&gt;</pre><h4>Kanban Card Template Rename</h4><p>The kanban template name changed from kanban-card to card, and the internal structure was simplified with dedicated &lt;header&gt;, &lt;main&gt;, and &lt;footer&gt; elements:</p><pre>&lt;!-- Odoo 16 --&gt;<br>&lt;kanban&gt;<br>    &lt;templates&gt;<br>        &lt;t t-name=&quot;kanban-card&quot;&gt;<br>            &lt;div class=&quot;oe_kanban_card oe_kanban_global_click&quot;&gt;<br>                &lt;div class=&quot;o_kanban_record_top&quot;&gt;<br>                    &lt;strong&gt;&lt;field name=&quot;name&quot;/&gt;&lt;/strong&gt;<br>                &lt;/div&gt;<br>                &lt;div class=&quot;o_kanban_record_bottom&quot;&gt;<br>                    &lt;div class=&quot;oe_kanban_bottom_left&quot;&gt;<br>                        &lt;field name=&quot;priority&quot; widget=&quot;priority&quot;/&gt;<br>                    &lt;/div&gt;<br>                    &lt;div class=&quot;oe_kanban_bottom_right&quot;&gt;<br>                        &lt;field name=&quot;user_id&quot; widget=&quot;many2one_avatar_user&quot;/&gt;<br>                    &lt;/div&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>        &lt;/t&gt;<br>    &lt;/templates&gt;<br>&lt;/kanban&gt;<br><br>&lt;!-- Odoo 17+ --&gt;<br>&lt;kanban&gt;<br>    &lt;templates&gt;<br>        &lt;t t-name=&quot;card&quot;&gt;<br>            &lt;field name=&quot;name&quot; class=&quot;fw-bold&quot;/&gt;<br>            &lt;footer&gt;<br>                &lt;field name=&quot;priority&quot; widget=&quot;priority&quot;/&gt;<br>                &lt;field name=&quot;user_id&quot; widget=&quot;many2one_avatar_user&quot; class=&quot;ms-auto&quot;/&gt;<br>            &lt;/footer&gt;<br>        &lt;/t&gt;<br>    &lt;/templates&gt;<br>&lt;/kanban&gt;</pre><p><strong>t-raw to </strong><strong>t-out</strong></p><p>t-raw rendered unescaped HTML -- a walking XSS vulnerability. It&#39;s removed in 17+. Use t-out instead, which auto-escapes strings but renders Markup() objects as HTML.</p><pre>&lt;!-- Odoo 16 -- XSS risk --&gt;<br>&lt;div t-raw=&quot;record.description&quot;/&gt;<br><br>&lt;!-- Odoo 17+ -- safe by default --&gt;<br>&lt;div t-out=&quot;record.description&quot;/&gt;</pre><p>Also, t-esc (which was the safe option in 16) is deprecated in favor of t-out. One directive to rule them all.</p><h4>Complete Form View Migration</h4><p>Here’s a full before/after for a form view, showing every change in context:</p><pre>&lt;!-- Odoo 16 --&gt;<br>&lt;form string=&quot;Sale Order&quot;&gt;<br>    &lt;header&gt;<br>        &lt;button name=&quot;action_confirm&quot; type=&quot;object&quot; string=&quot;Confirm&quot;<br>            attrs=&quot;{&#39;invisible&#39;: [(&#39;state&#39;, &#39;!=&#39;, &#39;draft&#39;)]}&quot;/&gt;<br>        &lt;button name=&quot;action_cancel&quot; type=&quot;object&quot; string=&quot;Cancel&quot;<br>            attrs=&quot;{&#39;invisible&#39;: [(&#39;state&#39;, &#39;in&#39;, [&#39;cancel&#39;, &#39;done&#39;])]}&quot;/&gt;<br>        &lt;field name=&quot;state&quot; widget=&quot;statusbar&quot; statusbar_visible=&quot;draft,sale,done&quot;/&gt;<br>    &lt;/header&gt;<br>    &lt;sheet&gt;<br>        &lt;div class=&quot;oe_title&quot;&gt;<br>            &lt;h1&gt;&lt;field name=&quot;name&quot; attrs=&quot;{&#39;readonly&#39;: [(&#39;state&#39;, &#39;!=&#39;, &#39;draft&#39;)]}&quot;/&gt;&lt;/h1&gt;<br>        &lt;/div&gt;<br>        &lt;group&gt;<br>            &lt;group&gt;<br>                &lt;field name=&quot;partner_id&quot;<br>                    attrs=&quot;{&#39;readonly&#39;: [(&#39;state&#39;, &#39;not in&#39;, [&#39;draft&#39;, &#39;sent&#39;])]}&quot;/&gt;<br>                &lt;field name=&quot;date_order&quot;<br>                    attrs=&quot;{&#39;required&#39;: [(&#39;state&#39;, &#39;=&#39;, &#39;sale&#39;)]}&quot;/&gt;<br>            &lt;/group&gt;<br>            &lt;group&gt;<br>                &lt;field name=&quot;warehouse_id&quot;<br>                    attrs=&quot;{&#39;invisible&#39;: [(&#39;picking_policy&#39;, &#39;=&#39;, &#39;direct&#39;)]}&quot;/&gt;<br>            &lt;/group&gt;<br>        &lt;/group&gt;<br>        &lt;notebook&gt;<br>            &lt;page string=&quot;Order Lines&quot;&gt;<br>                &lt;field name=&quot;order_line&quot;<br>                    attrs=&quot;{&#39;readonly&#39;: [(&#39;state&#39;, &#39;in&#39;, [&#39;done&#39;, &#39;cancel&#39;])]}&quot;&gt;<br>                    &lt;tree editable=&quot;bottom&quot;&gt;<br>                        &lt;field name=&quot;product_id&quot;/&gt;<br>                        &lt;field name=&quot;qty_delivered&quot;<br>                            attrs=&quot;{&#39;column_invisible&#39;: [(&#39;parent.state&#39;, &#39;=&#39;, &#39;draft&#39;)]}&quot;/&gt;<br>                    &lt;/tree&gt;<br>                &lt;/field&gt;<br>            &lt;/page&gt;<br>        &lt;/notebook&gt;<br>    &lt;/sheet&gt;<br>    &lt;div class=&quot;oe_chatter&quot;&gt;<br>        &lt;field name=&quot;message_follower_ids&quot; widget=&quot;mail_followers&quot;/&gt;<br>        &lt;field name=&quot;activity_ids&quot; widget=&quot;mail_activity&quot;/&gt;<br>        &lt;field name=&quot;message_ids&quot; widget=&quot;mail_thread&quot;/&gt;<br>    &lt;/div&gt;<br>&lt;/form&gt;</pre><pre>&lt;!-- Odoo 17+ (migrated) --&gt;<br>&lt;form string=&quot;Sale Order&quot;&gt;<br>    &lt;header&gt;<br>        &lt;button name=&quot;action_confirm&quot; type=&quot;object&quot; string=&quot;Confirm&quot;<br>            invisible=&quot;state != &#39;draft&#39;&quot;/&gt;<br>        &lt;button name=&quot;action_cancel&quot; type=&quot;object&quot; string=&quot;Cancel&quot;<br>            invisible=&quot;state in (&#39;cancel&#39;, &#39;done&#39;)&quot;/&gt;<br>        &lt;field name=&quot;state&quot; widget=&quot;statusbar&quot; statusbar_visible=&quot;draft,sale,done&quot;/&gt;<br>    &lt;/header&gt;<br>    &lt;sheet&gt;<br>        &lt;div class=&quot;oe_title&quot;&gt;<br>            &lt;h1&gt;&lt;field name=&quot;name&quot; readonly=&quot;state != &#39;draft&#39;&quot;/&gt;&lt;/h1&gt;<br>        &lt;/div&gt;<br>        &lt;group&gt;<br>            &lt;group&gt;<br>                &lt;field name=&quot;partner_id&quot;<br>                    readonly=&quot;state not in (&#39;draft&#39;, &#39;sent&#39;)&quot;/&gt;<br>                &lt;field name=&quot;date_order&quot;<br>                    required=&quot;state == &#39;sale&#39;&quot;/&gt;<br>            &lt;/group&gt;<br>            &lt;group&gt;<br>                &lt;field name=&quot;warehouse_id&quot;<br>                    invisible=&quot;picking_policy == &#39;direct&#39;&quot;/&gt;<br>            &lt;/group&gt;<br>        &lt;/group&gt;<br>        &lt;notebook&gt;<br>            &lt;page string=&quot;Order Lines&quot;&gt;<br>                &lt;field name=&quot;order_line&quot;<br>                    readonly=&quot;state in (&#39;done&#39;, &#39;cancel&#39;)&quot;&gt;<br>                    &lt;list editable=&quot;bottom&quot;&gt;<br>                        &lt;field name=&quot;product_id&quot;/&gt;<br>                        &lt;field name=&quot;qty_delivered&quot;<br>                            column_invisible=&quot;parent.state == &#39;draft&#39;&quot;/&gt;<br>                    &lt;/list&gt;<br>                &lt;/field&gt;<br>            &lt;/page&gt;<br>        &lt;/notebook&gt;<br>    &lt;/sheet&gt;<br>    &lt;chatter/&gt;<br>&lt;/form&gt;</pre><p>Notice every change: attrs dicts become inline expressions, &lt;tree&gt; becomes &lt;list&gt;, column_invisible uses parent. syntax directly, and the entire chatter boilerplate collapses into &lt;chatter/&gt;.</p><h3>⚠️ Controllers: Small Change, Serious Consequences</h3><p><strong>type=&quot;json&quot; vs </strong><strong>type=&quot;jsonrpc&quot;</strong></p><p>Odoo 17 introduced a distinction between plain JSON endpoints and JSON-RPC protocol endpoints. The web client’s internal calls now use type=&quot;jsonrpc&quot; for the standard JSON-RPC 2.0 protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tws33vayZc8wg3QndDrR-A.png" /><figcaption><em>Odoo Controller Types: http vs json vs jsonrpc — When to Use Each</em></figcaption></figure><pre># Odoo 16<br>@http.route(&quot;/my_module/get_data&quot;, type=&quot;json&quot;, auth=&quot;user&quot;)<br>def get_data(self, **kwargs):<br>    return {&quot;data&quot;: request.env[&quot;my.model&quot;].search([]).read([&quot;name&quot;])}<br><br># Odoo 17+ -- for endpoints called by the Odoo web client<br>@http.route(&quot;/my_module/get_data&quot;, type=&quot;jsonrpc&quot;, auth=&quot;user&quot;)<br>def get_data(self, **kwargs):<br>    return {&quot;data&quot;: request.env[&quot;my.model&quot;].search([]).read([&quot;name&quot;])}</pre><h4>Bearer Token Authentication (17+)</h4><p>Odoo 17 introduced auth=&quot;bearer&quot; for API token authentication, which is a much cleaner pattern for external integrations:</p><pre># Odoo 17+: Bearer token auth for external API consumers<br>@http.route(&quot;/api/v1/resource&quot;, auth=&quot;bearer&quot;, type=&quot;json&quot;)<br>def api_resource(self):<br>    return {&quot;user&quot;: request.env.user.name}</pre><h3>💅 Assets and SCSS: The Sass Saga</h3><h4>LibSass to Dart Sass</h4><p>Odoo 17+ switched from libsass (deprecated upstream) to dart-sass. This breaks two things: the division operator and @import statements.</p><p><strong>Division operator:</strong></p><pre>// Odoo 16 (libsass) -- worked fine<br>.element {<br>    width: 100px / 2;       // = 50px<br>    font-size: 24px / 1.5;  // = 16px<br>}<br><br>// Odoo 17+ (dart-sass) -- division with / is treated as CSS slash<br>@use &quot;sass:math&quot;;<br><br>.element {<br>    width: math.div(100px, 2);       // = 50px<br>    font-size: math.div(24px, 1.5);  // = 16px<br>}<br><br>// Alternative: use CSS calc() -- works everywhere<br>.element {<br>    width: calc(100px / 2);<br>}</pre><p><strong>@import to @use/@forward:</strong></p><pre>// Odoo 16 (libsass)<br>@import &quot;variables&quot;;<br>@import &quot;mixins&quot;;<br><br>.element {<br>    color: $primary-color;<br>    @include my-mixin();<br>}<br><br>// Odoo 17+ (dart-sass)<br>@use &quot;variables&quot; as vars;<br>@use &quot;mixins&quot; as mix;<br><br>.element {<br>    color: vars.$primary-color;<br>    @include mix.my-mixin();<br>}<br><br>// Or with wildcard namespace (closest to old behavior)<br>@use &quot;variables&quot; as *;<br>@use &quot;mixins&quot; as *;<br><br>.element {<br>    color: $primary-color;<br>    @include my-mixin();<br>}</pre><h3>🆕 What’s New in Odoo 18 and 19</h3><p>After the 16-to-17 gauntlet, the 17-to-18-to-19 journey is more of a scenic hike than a death march.</p><p><strong>models.Constraint (Odoo 18+)</strong></p><p>A new declarative approach for SQL constraints that provides better ORM integration:</p><pre># Odoo 16/17 -- still valid in 18, but the old way<br>_sql_constraints = [<br>    (&#39;unique_ref&#39;, &#39;UNIQUE(default_code)&#39;, &#39;Product reference must be unique.&#39;),<br>    (&#39;positive_price&#39;, &#39;CHECK(list_price &gt;= 0)&#39;, &#39;Price must be non-negative.&#39;),<br>]<br><br># Odoo 18+ -- the new way<br>from odoo.models import Constraint<br><br>_constraints = [<br>    Constraint(&#39;unique_ref&#39;, &#39;UNIQUE(default_code)&#39;, &#39;Product reference must be unique.&#39;),<br>    Constraint(&#39;positive_price&#39;, &#39;CHECK(list_price &gt;= 0)&#39;, &#39;Price must be non-negative.&#39;),<br>]</pre><p>Note that _sql_constraints still works across all versions. The Constraint class is the direction Odoo is heading.</p><h4>Python 3.12 (Odoo 18+) and 3.11 Minimum (Odoo 19)</h4><p>Key deprecations to watch:</p><ul><li>datetime.datetime.utcnow() is deprecated. Use datetime.datetime.now(datetime.timezone.utc).</li><li>The distutils module is removed entirely in 3.12.</li><li>Performance improvements of 10–60% over 3.10.</li><li>Odoo 19 raises the floor to Python 3.11 minimum.</li></ul><h4>Content Security Policy Tightening (18 and 19)</h4><p>Odoo 18+ enforces stricter CSP headers. If your module dynamically injects scripts or loads from CDNs, it will break:</p><pre># This pattern BREAKS in Odoo 18+ (CSP blocks inline script creation)<br># No more document.createElement(&quot;script&quot;) with external URLs<br><br># Instead, vendor libraries into your module and declare them in assets:<br>&quot;assets&quot;: {<br>    &quot;web.assets_backend&quot;: [<br>        &quot;my_module/static/lib/some-library/some-library.min.js&quot;,<br>        &quot;my_module/static/src/js/my_component.js&quot;,<br>    ],<br>},</pre><p>No inline &lt;script&gt; tags in QWeb templates either. Everything must go through the asset bundle system.</p><h4>Dart Sass Enforcement (Odoo 18)</h4><p>While Odoo 17 introduced dart-sass, Odoo 18 fully enforces it. Any SCSS files still using / for division or @import will fail compilation.</p><h4>Manifest Changes</h4><ul><li><strong>license field is mandatory</strong> starting in Odoo 17. Omitting it will raise a warning in 16 and an error in 17+.</li><li><strong>post_init_hook signature changed</strong> in 17+: it now receives env directly instead of (cr, registry).</li></ul><pre># Odoo 16<br>def post_init_hook(cr, registry):<br>    from odoo import api, SUPERUSER_ID<br>    env = api.Environment(cr, SUPERUSER_ID, {})<br>    # ...<br><br># Odoo 17+<br>def post_init_hook(env):<br>    # env is ready to use<br>    env[&quot;my.model&quot;].search([])._compute_something()</pre><p><strong>Testing: </strong><strong>SavepointCase Removed (17+)</strong></p><p>SavepointCase is gone in 17+. Use TransactionCase, which now handles savepoints automatically when setUpClass is defined:</p><pre># Odoo 16<br>from odoo.tests.common import SavepointCase  # Works<br><br># Odoo 17+ -- ImportError! Use TransactionCase instead.<br>from odoo.tests import common<br>class TestMyModel(common.TransactionCase):<br>    @classmethod<br>    def setUpClass(cls):<br>        super().setUpClass()<br>        cls.shared_record = cls.env[&quot;my.model&quot;].create({&quot;name&quot;: &quot;Shared&quot;})</pre><p><strong>Reports: </strong><strong>_render_qweb_pdf Deprecation</strong></p><p>The _render_qweb_pdf() method is deprecated in 17 and removed in 18+. Use _render() instead:</p><pre># Odoo 16<br>pdf_content, content_type = self.env[&quot;ir.actions.report&quot;]._render_qweb_pdf(<br>    report_action, res_ids=self.ids<br>)<br><br># Odoo 17+<br>report = self.env.ref(&quot;my_module.action_report_my_document&quot;)<br>pdf_content, mime = report._render(self.ids)</pre><h4>Mail and Chatter</h4><p>Two notable changes:</p><p><strong>&lt;chatter/&gt; shorthand</strong> (17+): Replaces the verbose three-field boilerplate with a single tag.</p><p><strong>Markup for </strong><strong>message_post</strong>: The body parameter in message_post must be a Markup object for HTML content in 17+, as shown in the Markup section above.</p><h3>✅ Part 1 Migration Checklist</h3><p>Print this. Tape it to your monitor.</p><p><strong><em>16 to 17</em></strong></p><ul><li>Replace all attrs= with inline invisible=, readonly=, required=</li><li>Remove all states= attributes; replace with invisible=&quot;state not in (...)&quot;</li><li>Migrate name_get() overrides to _compute_display_name()</li><li>Adopt Command objects for O2M/M2M operations (replace tuple syntax)</li><li>Wrap HTML strings in Markup(), always escape() user input</li><li>Replace read_group(lazy=...) calls with _read_group() using aggregates</li><li>Replace invalidate_cache() with invalidate_model() / invalidate_recordset()</li><li>Replace flush() with flush_model() / flush_recordset()</li><li>Rename &lt;tree&gt; to &lt;list&gt; in views and XPath targets</li><li>Update kanban templates: kanban-card to card</li><li>Replace t-raw with t-out, t-esc with t-out</li><li>Switch controllers from type=&quot;json&quot; to type=&quot;jsonrpc&quot; where appropriate</li><li>Add &quot;license&quot;: &quot;LGPL-3&quot; to __manifest__.py (mandatory)</li><li>Update post_init_hook signature from (cr, registry) to (env)</li><li>Replace SavepointCase with TransactionCase in tests</li><li>Add &lt;chatter/&gt; shorthand or verify chatter field order in form views</li><li>Update SCSS: start migration from @import to @use/@forward</li></ul><p><strong><em>17 to 18</em></strong></p><ul><li>Ensure Python 3.12 compatibility (fix utcnow(), distutils, etc.)</li><li>Migrate _sql_constraints to models.Constraint (or leave as-is -- both work)</li><li>Complete SCSS dart-sass migration (division operator, @import removal)</li><li>Remove inline script injection or CDN loads that violate CSP</li><li>Vendor third-party JS libraries into static folder, register in asset bundles</li><li>Replace _render_qweb_pdf() with _render()</li><li>Test all frontend components for CSP errors in browser console</li></ul><p><strong><em>18 to 19</em></strong></p><ul><li>Update Python minimum to 3.11</li><li>Update version to 19.0.x.x.x in manifest</li><li>Audit all HTTP routes for stricter security checks</li><li>Review Constraint definitions for latest patterns</li><li>Run odoo-bin --update=all in staging before touching production</li></ul><p>· · ·</p><h3>🕳️ Common Pitfalls (Part 1 Scope)</h3><p>These are the mistakes that will cost you hours. Learn from our suffering.</p><h4><strong>Pitfall 1: The Inverted Invisible</strong></h4><p>When migrating attrs, it&#39;s surprisingly easy to invert the logic. The old states=&quot;draft&quot; meant &quot;show when draft&quot;, but the new syntax uses invisible which means &quot;hide when...&quot;:</p><pre>&lt;!-- WRONG (logic is inverted) --&gt;<br>&lt;button invisible=&quot;state != &#39;draft&#39;&quot; .../&gt;<br>&lt;!-- This HIDES when state is NOT draft. Is that what you meant? --&gt;<br><br>&lt;!-- Careful: states=&quot;draft&quot; meant VISIBLE when draft --&gt;<br>&lt;!-- So the correct invisible equivalent is: --&gt;<br>&lt;button invisible=&quot;state != &#39;draft&#39;&quot; .../&gt;<br>&lt;!-- Actually this IS correct. But double-check every single one. --&gt;</pre><p>The trap: states=&quot;draft,sent&quot; meant &quot;visible when state is draft OR sent&quot;. The equivalent invisible is invisible=&quot;state not in (&#39;draft&#39;, &#39;sent&#39;)&quot;. Miss one not and your button vanishes.</p><h4>Pitfall 2: The Phantom JSON Endpoint</h4><p>Forgetting to change type=&quot;json&quot; to type=&quot;jsonrpc&quot; for endpoints called by Odoo&#39;s web client. Your AJAX calls will silently fail with cryptic 404s or JSON parsing errors.</p><h4>Pitfall 3: The Markup XSS Trap</h4><pre># WRONG -- f-string inside Markup does NOT escape!<br>from markupsafe import Markup<br>name = &quot;&lt;script&gt;alert(&#39;hacked&#39;)&lt;/script&gt;&quot;<br>body = Markup(f&quot;&lt;p&gt;Hello {name}&lt;/p&gt;&quot;)  # XSS vulnerability!<br><br># RIGHT -- use % formatting or escape() explicitly<br>from markupsafe import Markup, escape<br>body = Markup(&quot;&lt;p&gt;Hello %s&lt;/p&gt;&quot;) % escape(name)<br># Result: &quot;&lt;p&gt;Hello &amp;lt;script&amp;gt;alert(&amp;#39;hacked&amp;#39;)&amp;lt;/script&amp;gt;&lt;/p&gt;&quot;</pre><p>The key insight: Markup() marks the whole string as safe, including whatever&#39;s inside the f-string. Use % formatting with Markup -- it auto-escapes string arguments.</p><h4>Pitfall 4: SCSS Division That Isn’t</h4><pre>// Dart-sass treats this as CSS &quot;slash&quot; notation, NOT division<br>.element { font-size: 24px / 1.5; }  // Outputs literally &quot;24px / 1.5&quot;<br><br>// You need:<br>@use &quot;sass:math&quot;;<br>.element { font-size: math.div(24px, 1.5); }  // Outputs 16pxsss</pre><h4>Pitfall 5: The Command Import</h4><pre># WRONG<br>from odoo.fields import Command  # ImportError!<br><br># RIGHT<br>from odoo import Command<br># Or:<br>from odoo import models, fields, api, Command</pre><h3>⚡ TL;DR — The Quick Reference</h3><p>Migrating Odoo 16 to 17 to 18 to 19? Here’s the one-minute version for Part 1:</p><ol><li><strong>attrs is gone</strong> -- replace with inline invisible=, readonly=, required=</li><li><strong>name_get() is deprecated</strong> -- use _compute_display_name() instead</li><li><strong>&lt;tree&gt; becomes </strong><strong>&lt;list&gt;</strong> -- rename in views and XPath targets</li><li><strong>t-raw is removed</strong> -- use t-out everywhere</li><li><strong>HTTP controllers</strong>: type=&quot;json&quot; to type=&quot;jsonrpc&quot; for Odoo RPC calls</li><li><strong>Use </strong><strong>Command objects</strong> instead of magic integer tuples for O2M/M2M writes</li><li><strong>Wrap HTML in </strong><strong>Markup()</strong> and always escape() user input</li><li><strong>flush() and </strong><strong>invalidate_cache()</strong> become flush_model() / invalidate_model()</li><li><strong>SCSS</strong>: @import to @use, / to math.div() or calc()</li><li><strong>Odoo 18+</strong>: models.Constraint, Python 3.12, stricter CSP, Dart Sass enforced</li><li><strong>Odoo 19</strong>: Python 3.11 minimum, incremental tightening across the board</li></ol><p>The 16-to-17 jump is the hardest. Plan twice the time you think you need. You’ll use it.</p><h3>🔮 Coming in Part 2: The JavaScript and OWL Deep Dive</h3><p>Part 1 covered the backend, XML, and SCSS. But we haven’t touched the <em>other</em> half of migration pain: JavaScript.</p><p><strong>Part 2 will cover:</strong></p><ul><li>OWL 1.x to OWL 2.x: The complete component migration guide</li><li>Lifecycle methods to hooks (willStart to onWillStart, etc.)</li><li>Legacy widgets to OWL components (with full before/after examples)</li><li>moment.js to luxon (and the silent date bug that will haunt you)</li><li>The OWL service system (useService for ORM, notifications, actions)</li><li>Tour system migration</li><li>Props validation (array to schema)</li><li>Parent-child communication patterns</li><li>The 5 most common JavaScript migration mistakes</li></ul><p>That wraps up the backend side of the Odoo migration journey. In <strong>Part 2</strong>, we’ll tackle the frontend — OWL components, services, and everything JavaScript. 🚀</p><p>If you found this guide useful, feel free to share it with fellow Odoo developers. 🔄 Questions, corrections, or war stories from your own migrations? Drop a comment — I’d love to hear from you. 💬</p><p>— <a href="https://www.linkedin.com/in/osama-alhalabi-56b4181a8/&#39;">Osama Alhalabi</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb6da9fee854" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>