Upgrading custom Odoo modules from 17 to 19: what breaks and why
A custom Odoo 17 module with list views doesn't install on 18 or 19 until its views change. After that come removed methods, renamed fields, and changes that raise no error at all. Here is each one, with the reason it breaks.
On this page
A custom module written for Odoo 17 breaks on 19 in three ways. Some changes stop it installing: <tree> views, a 17.0 version number, fields that were renamed. Some make it fail when a user clicks: removed methods such as user_has_groups(). And some change behaviour without any error: 19 ignores _sql_constraints, and turns a single-record create() into a crash that a broad except can hide. Each change below names the Odoo source that causes it, checked against 17.0, 18.0 and 19.0.
The examples come from a sample audit report on a purpose-built demo module, installed and tested on all three versions.
Is this about the database or the code?
The code. An upgrade has two separate jobs: migrating the database, and making the custom modules work on the target version. This post is about the second.
The database moves directly from source to target: from Odoo 6.0 to the latest release in one project, without running each intermediate upgrade yourself. The custom modules are different. Their code has to work on 19, which means handling what changed in 18 and in 19, whatever route the data takes. See Odoo upgrades for how both jobs fit in one project.
What stops a 17 module from installing on 19?
The version number
Odoo checks that a module’s version belongs to the running series. 17.0.1.0.0 is rejected on 18 and on 19: Modules should have a version in format x.y, x.y.z, 19.0.x.y or 19.0.x.y.z (18 names its own series). Use 19.0.1.0.0, or a short version like 1.0 that Odoo prefixes itself.
Why: odoo/modules/module.py → adapt_version() (18) and check_version() (19).
<tree> views
18 renamed the list view type from tree to list. A module with <tree> views fails to install: 18 stops with Wrong value for ir.ui.view.type: 'tree', 19 with Invalid view type: 'tree'. view_mode values in XML actions change the same way.
Why: the view type is a selection field, and from 18 its values are list, form, graph and so on, with no tree (odoo/addons/base/models/ir_ui_view.py → View.type).
Renamed fields in data files
19 renamed groups_id to group_ids on users, views, menus, window actions and server actions, and users to user_ids on groups. On 19 the old names don’t exist at all, so a menu or view record that sets groups_id fails to load, and so does Python code that reads it.
Why: the field definitions in odoo/addons/base/models/res_users.py, res_groups.py, ir_ui_menu.py, ir_ui_view.py and ir_actions.py (19).
Business apps renamed fields too. Two that custom sales and inventory code often touches:
sale.order.line.product_uomisproduct_uom_idin 19 (addons/sale/models/sale_order_line.py).product.template.type == "product"no longer exists from 18. The types areconsu,serviceandcombo, and stock tracking is the booleanis_storable(addons/product/models/product_template.py,addons/stock/models/product.py).
attrs and states in views already fail on 17, so a module that runs on 17 has already dropped them.
What fails when someone uses the module?
These install cleanly and break on first use.
Methods that 18 removed
self.user_has_groups("...") exists on 17 and not on 18 or 19. Call it, and you get AttributeError. In the sample report it computes a field on the sale order form, so on 18 and 19 the form doesn’t open at all. Use self.env.user.has_group("..."), which exists on all three versions.
name_get() was already ignored on 17: display_name is computed without it. 18 removed it from the base model. An override does nothing, and records of a model without a name field show as commission.line,7. Move the logic to _compute_display_name().
Why: odoo/models.py → BaseModel.user_has_groups() and BaseModel.name_get() exist in 17 only.
Actions returned from Python with tree
On 17, an action returned from a button with "view_mode": "tree,form" worked because the web controller translated tree to list before sending the action to the browser. 18 removed that translation, so the same button now raises No default view of type 'tree' could be found!.
Why: addons/web/controllers/utils.py → fix_view_modes(), called by clean_action() in 17 and gone in 18.
create() overridden for one record
@api.model
def create(self, vals):
if not vals.get("rate"):
...
On 17 this works, with a warning that the model “is not overriding the create method in batch”. On 18 it is a DeprecationWarning. On 19, @api.model on a method named create is treated as @api.model_create_multi, so vals is a list and vals.get raises AttributeError: 'list' object has no attribute 'get'.
Why: odoo/api.py → model() wraps create with model_create_single() in 17 and 18; odoo/orm/decorators.py → model() wraps it with model_create_multi() in 19.
Fix:
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if not vals.get("rate"):
...
return super().create(vals_list)
Deprecated, still working
These keep working on 19 but log warnings, and the warnings are worth clearing now:
| Odoo 17 | Replacement | Since |
|---|---|---|
group_operator="avg" | aggregator="avg" | 18 |
check_access_rights(op) and check_access_rule(op) | check_access(op) | 18 |
read_group() in Python | _read_group() or formatted_read_group() | 19 |
self._context, self._uid | self.env.context, self.env.uid | 19 |
@http.route(type="json") | @http.route(type="jsonrpc") | 19 |
What changes without an error?
These are the expensive ones, because nothing tells you.
_sql_constraints are ignored on 19
19 no longer reads _sql_constraints. It logs Model attribute '_sql_constraints' is no longer supported, please define model.Constraint on the model. and doesn’t create the constraint. On a database installed on 19, records that the constraint used to reject are now saved. The sample report proves it: on 18, a duplicate commission rule raises IntegrityError; on 19 the same duplicate is accepted.
_user_company_uniq = models.Constraint(
"UNIQUE(user_id, company_id)",
"A salesperson can only have one commission rule per company.",
)
Why: odoo/orm/model_classes.py (the warning) and odoo/orm/table_objects.py → class Constraint (19).
A crash that a broad except hides
Put the 19 create() change next to this pattern from hastily written modules:
try:
self.env["commission.line"].create({...})
except Exception:
pass
On 19 the module installs, orders confirm, and no commission line is ever created. There is no error on screen and nothing in the log. In the sample report, only a test caught it.
Units of measure
19 removed uom.category. A unit now points to a reference unit through relative_uom_id, and factor is the absolute quantity: Dozens has a factor of 12 on 19, against 1/12 on 17. Code that converts quantities with its own factor arithmetic, rather than through _compute_quantity(), gets wrong quantities without an error. Domains on category_id fail outright with Invalid field uom.uom.category_id. Dozens also ships archived on a new 19 database.
Why: addons/uom/models/uom_uom.py and addons/uom/data/uom_data.xml (17 and 19).
Searches for values that no longer exist
A domain like [("type", "=", "product")] on products raises no error on 18 or 19. It matches nothing, because product is no longer a product type. Reports and scheduled jobs built on it go quiet.
How do you port a module from 17 to 19 safely?
In this order:
- Bump the version to
19.0.x.y.z. - Search for the known changes:
<tree,view_modewithtree,groups_id,user_has_groups,name_get,@api.modelabovecreate,_sql_constraints,group_operator,read_group(,type="json",_context,product_uomon sale lines,type == "product",uom.category. The Odoo Custom Module Health Checklist has the full list, with search commands and sources. - Install on a new, empty 19 database and run the module’s tests. Read the log for
DeprecationWarningand “no longer supported”. - Test what fails silently: uniqueness rules, record creation in every flow, quantity conversions, and any search on a selection value.
- Only then migrate a copy of the database and test with real data.
Step 4 is where the sample module’s worst problems were hiding.
If you’d rather know what breaks before the project starts, the Odoo Code Audit includes upgrade notes for your target version. For the move itself, see Odoo upgrades, and for the 17 to 18 changes in accounting, reports and the web client, Odoo 17 to 18: what changed and what breaks.