Technical
Odoo Module Upgrade Checklist: Moving Custom Code to the Next Version
A practical developer checklist for upgrading a custom Odoo module one major version: manifest, attrs to Python expressions, deprecated APIs, OWL changes, migration scripts and tests.
Kalvyai Engineering · · Updated · 6 min read

On this page
This is the checklist we use when moving a custom Odoo module up one major version. The examples focus on the 16.0 → 17.0 and 17.0 → 18.0 jumps, because those are where most custom code breaks. Every version has its own changes, so treat this as a structure and confirm each detail against the source code of the target version.
Before you touch the code
- Upgrade one major version at a time. Going from 16.0 to 18.0 means doing 16 → 17, testing, then 17 → 18. Skipping versions hides which change broke what.
- Get a recent copy of the production database and restore it on a staging server. Run
odoo-bin neutralizeon it so it does not send emails or call live payment and shipping APIs. - Plan the standard database upgrade separately. Your module's migration scripts run on top of a database that has already been upgraded for standard Odoo modules. That step is done through the upgrade path you use for your edition, such as Odoo's upgrade service for Enterprise or OpenUpgrade for Community.
- Inventory the module. List every model it inherits, every view it extends, every JS file in its assets and every external API it calls. Inherited standard views and patched JS components are where most surprises come from.
- Create a branch per target version and check out the matching Odoo source (and Enterprise, if you depend on it).
1. Manifest
Start with __manifest__.py, because Odoo will refuse to load the module if it is wrong.
{
"name": "Sale Approval Extras",
"version": "17.0.1.0.0", # was 16.0.1.3.0
"license": "LGPL-3",
"depends": ["sale_management", "mail"],
"data": [
"security/ir.model.access.csv",
"views/sale_order_views.xml",
],
"assets": {
"web.assets_backend": [
"sale_approval_extras/static/src/**/*",
],
},
"installable": True,
}Check:
- Version prefix matches the target series (
17.0.x.y.z). Migration scripts are keyed on this number, so decide your new version now. - Dependencies still exist under the same technical names. Standard modules are sometimes renamed, merged or split between versions. Check your target version's release notes for renamed, merged or split modules.
- Assets are declared in the
assetskey, not through XML template inheritance of asset bundles. Confirm the bundle names you use still exist in the target version. - License is set. Missing licenses produce warnings on load.
2. Views
Replace attrs and states with Python expressions (17.0)
Odoo 17.0 removed the attrs and states attributes. Modifiers are now written directly as attributes, using Python-like expressions instead of domains.
- <field name="discount_reason"
- attrs="{'invisible': [('discount', '=', 0)], 'required': [('discount', '>', 10)]}"/>
+ <field name="discount_reason"
+ invisible="discount == 0"
+ required="discount > 10"/>
- <button name="action_approve" type="object" states="draft,sent"/>
+ <button name="action_approve" type="object" invisible="state not in ('draft', 'sent')"/>Conversion rules that cover most cases:
('field', '=', value)becomesfield == value.'|'and'&'prefix operators becomeorandand, written in normal infix order. Double-check operator precedence when you translate nested domains.states="a,b"becomesinvisible="state not in ('a', 'b')".- In list views, hiding a whole column based on context or parent values uses
column_invisible, notinvisible. - Fields used in an expression must be present in the view. Add them with
invisible="1"if they should not be shown.
Do not forget inherited views. An xpath with position="attributes" that sets attrs must be rewritten to set invisible, readonly or required individually.
<xpath expr="//field[@name='client_order_ref']" position="attributes">
<attribute name="readonly">state != 'draft'</attribute>
</xpath>Rename tree to list (18.0)
In 18.0, list views use the <list> root tag instead of <tree>, and window actions use list in view_mode instead of tree. Update view arches, view_mode values in actions, and any Python code that builds actions with 'view_mode': 'tree,form'.
Chatter markup (18.0)
Form views in 18.0 use a <chatter/> element instead of the older <div class="oe_chatter"> block with its message_follower_ids, activity_ids and message_ids fields. Check which chatter options your own models need in the target version.
Find everything quickly
grep -rn "attrs=\|states=" --include=*.xml my_module/
grep -rn "<tree\|view_mode.*tree" --include=*.xml --include=*.py my_module/
grep -rn "oe_chatter" --include=*.xml my_module/Then load the module. Odoo validates views at install time, and the error messages usually point to the exact line.
3. Deprecated and removed Python APIs
Run the module on the target version with warnings visible in the log and search for DeprecationWarning. Some common changes:
name_get→_compute_display_name(17.0).display_nameis now a computed field you override.group_operator→aggregator(18.0) on field definitions._check_recursion→_has_cycle(18.0).user_has_groups→self.env.user.has_groupin recent versions.read_group/_read_group: the signature and return format of_read_groupchanged in 17.0. If you override or call it, re-read the target version's implementation. Check the signature in your target version's source code.
Example of the name_get change:
# 16.0
def name_get(self):
return [(rec.id, f"[{rec.code}] {rec.name}") for rec in self]
# 17.0+
@api.depends("code", "name")
def _compute_display_name(self):
for rec in self:
rec.display_name = f"[{rec.code}] {rec.name}"Also check every standard method you override with super(). If the parent method's signature changed, your override may still load but silently pass the wrong arguments. Compare each override against the target version's source, not your memory of the old one.
4. OWL frontend changes
The frontend usually takes the most time. Key points for 17.0 and 18.0:
Legacy widgets are gone (17.0)
Code built on the old web.Widget, AbstractField or legacy views must be rewritten as OWL components. There is no compatibility layer to lean on.
patch signature changed (17.0)
The patch name argument was removed, and this._super() is replaced by normal super calls.
// 16.0
patch(FormController.prototype, "sale_approval_extras.FormController", {
setup() {
this._super(...arguments);
this.notification = useService("notification");
},
});
// 17.0+
patch(FormController.prototype, {
setup() {
super.setup(...arguments);
this.notification = useService("notification");
},
});Field widgets register an object (17.0)
The fields registry expects an object with a component key rather than the component class directly.
export const discountBadgeField = {
component: DiscountBadgeField,
supportedTypes: ["float"],
};
registry.category("fields").add("discount_badge", discountBadgeField);The rpc service was removed (18.0)
Replace useService("rpc") with the rpc function import. For model calls, prefer the orm service.
import { rpc } from "@web/core/network/rpc";
const result = await rpc("/sale_approval_extras/summary", { order_id: id });Other things to check
- QWeb templates no longer need
owl="1". - Imports from
@web/...paths: files move between versions. A broken import shows as a module loading error in the browser console. - Open the backend with
?debug=assetsand keep the console open while clicking through every screen your module touches.
5. Data migration scripts
If field names, models or stored values change, you need migration scripts. Odoo runs them when the module's version in the manifest is higher than the version recorded in the database.
sale_approval_extras/
└── migrations/
└── 17.0.1.0.0/
├── pre-migrate.py
├── post-migrate.py
└── end-migrate.py- pre-migrate runs before the module's models and data are loaded. Use it for raw SQL schema work, such as renaming a column so the ORM does not drop it and create an empty new one.
- post-migrate runs after the module is loaded. You can use the ORM here.
- end-migrate runs after all modules in the update are loaded.
Each file defines migrate(cr, version):
# migrations/17.0.1.0.0/pre-migrate.py
def migrate(cr, version):
if not version:
return # fresh install, nothing to migrate
cr.execute("""
SELECT 1 FROM information_schema.columns
WHERE table_name = 'sale_order' AND column_name = 'x_approval_note'
""")
if cr.fetchone():
cr.execute(
"ALTER TABLE sale_order RENAME COLUMN x_approval_note TO approval_note"
)# migrations/17.0.1.0.0/post-migrate.py
from odoo import api, SUPERUSER_ID
def migrate(cr, version):
if not version:
return
env = api.Environment(cr, SUPERUSER_ID, {})
orders = env["sale.order"].search([("approval_state", "=", False)])
orders.write({"approval_state": "not_required"})Rules we follow:
- Make scripts idempotent. Check before you rename or insert, so a rerun after a failed upgrade does not break.
- Remember
noupdatedata. Records loaded withnoupdate="1"are not refreshed on update. If they must change, change them in post-migrate. - Log what you did with the standard
loggingmodule, including row counts. - Time the scripts on a full-size copy. A loop over 500,000 records with the ORM can take far longer than one SQL
UPDATE.
Run the upgrade on staging:
./odoo-bin -c odoo.conf -d staging_copy -u sale_approval_extras --stop-after-init6. Tests
Tests are what make the next upgrade cheaper.
- Fix existing tests first. They often use the same deprecated APIs as the module.
- Run them on a fresh database:
./odoo-bin -c odoo.conf -d test_db -i sale_approval_extras \
--test-enable --test-tags /sale_approval_extras --stop-after-init- Add tests for the behaviour you just touched, especially view modifiers and computed fields:
from odoo.tests import TransactionCase, Form, tagged
@tagged("post_install", "-at_install")
class TestApproval(TransactionCase):
def test_discount_reason_required(self):
partner = self.env["res.partner"].create({"name": "Test"})
form = Form(self.env["sale.order"])
form.partner_id = partner
with form.order_line.new() as line:
line.product_id = self.env.ref("product.product_product_4")
line.discount = 15
with self.assertRaises(AssertionError):
form.save() # discount_reason is required above 10%The product.product_product_4 reference comes from demo data, so this test needs a database with demo data installed. For production-like runs, create the product in the test instead.
- Add a tour with
HttpCase.start_tourfor the main user flow if your module changes the UI. - JS unit tests: 17.0 uses QUnit, while 18.0 moved web client tests to the Hoot framework. In 18.0, put JavaScript test files under the addon's /static/tests folder (e.g. /web/static/tests/env.test.js) and add them to the web.assets_unit_tests bundle.
- Test the migrated database, not just a fresh install. Upgrade a production copy, then check a short list of real records: counts before and after, key field values, and that old documents still open and print.
The short version
[ ] One major version at a time, on a neutralized production copy
[ ] Manifest: version, depends, assets, license
[ ] Views: attrs/states -> expressions, tree -> list, chatter, inherited views
[ ] Python: no DeprecationWarning in logs, overrides match new signatures
[ ] OWL: legacy widgets rewritten, patch(), field registry, rpc import
[ ] Migration scripts: idempotent, version-gated, timed on full data
[ ] Tests: unit, tour, and a check of the upgraded production copyHow Kalvyai can help
We upgrade and maintain custom Odoo modules for businesses that cannot afford a broken release, from view and OWL rewrites to migration scripts tested on real data. You can read more about our Odoo development work. If you want tooling for this, Upgrade Autopilot moves custom Odoo apps to the next version, automatically upgraded and tested. Our other apps are at store.kalvyai.com.
Have a module stuck on an older version? Contact us with the module list and your target version, and we will tell you what the upgrade involves.
Last updated 20 Nov 2026
- Odoo
- Odoo upgrade
- OWL
- migration scripts
- Python
- ERP development
Kalvyai Engineering · Engineering team
The engineers who build, connect and fix business systems at Kalvyai: Odoo, ERPNext, Shopify and AI agents that work inside them with approvals, budgets and an audit trail.



Comments
No comments yet. Questions and corrections are welcome.
Rate this post or leave a comment