Skip to content

[FIX] openupgrade_framework: auto-install only modules new in this version - #5

Merged
cursor[bot] merged 1 commit into
20.0from
cursor/ou-auto-01-new-modules-3e8f
Nov 12, 2026
Merged

cursor[bot] merged 1 commit into
20.0from
cursor/ou-auto-01-new-modules-3e8f

Conversation

@adekock11

Copy link
Copy Markdown
Owner

Symptom

On a database that started before Odoo 16 and was upgraded 16→17→18→19→20, iap had been uninstalled on purpose. Odoo 18 makes iap auto_install. OpenUpgrade's IrModuleModule.update_list patch calls button_install() on every uninstalled auto-install module whose dependencies are installed (except l10n_*). iap comes back, and with it iap_mail, iap_crm, crm_iap_enrich, crm_iap_mine, partner_autocomplete, snailmail and snailmail_account.

Root cause

The patch cannot tell a module that is new in this version from one that already existed and was left uninstalled. update_list() creates ir.module.module rows for addons that were not in the table yet; the patch then installs every uninstalled auto-install row.

The same patch is on OCA 18.0, 19.0 and this 20.0 tree. This pull request is against the fork's 20.0 only. The same change applies to OCA 18.0 and 19.0 (the 18.0/19.0 copies do not have the Odoo 20 Domain filter, but the snapshot logic is the same).

Change

openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_module.py

  • Snapshot ir.module.module.name before calling the original update_list.
  • Also treat every name in openupgrade_legacy_<major>_<minor>_ir_module_module as pre-existing. base pre-migration creates that table (SELECT name, state FROM ir_module_module), so a row that was deleted and recreated by a later update_list is still recognised. Table names are matched with a full regex and quoted with psycopg2.sql.Identifier.
  • Auto-install only modules that are not in that set, still uninstalled, auto_install, with dependencies in installed / to upgrade / to install, and still excluding l10n_* and country-specific modules for countries the database does not use.
  • IrModuleModule.update_list._original_method is still resolved at run time, the same way the 18.0/19.0/20.0 patches do it.

Opt out, restoring the old behaviour:

  • Odoo config: openupgrade_auto_install_existing = True
  • or environment: OPENUPGRADE_AUTO_INSTALL_EXISTING=1

Tests

test_03_update_list now creates a module before update_list and asserts it stays uninstalled, and stubs _original_method so a row created during the call becomes to install. A new l10n_* row created the same way stays uninstalled. test_04_update_list_install_existing sets the environment variable and asserts the pre-existing module is installed again.

Not executed here (no Odoo test database). ruff is clean on both files.

Upstream

No open or merged OCA pull request changes this behaviour (the existing update_list PRs, OCA#5167 and OCA#5337, only fix the return value and the decorator). Suitable for OCA 18.0, 19.0 and 20.0 once openupgrade_framework is on 20.0 (OCA OCA#6046 / OCA#6068). The 20.0 file uses odoo.fields.Domain; 18.0 and 19.0 keep their list domains.

Limitation

A module that is not in ir.module.module and not in any legacy table is treated as new. That is the intended case (the addon really appeared in this version). The opt-out is the escape hatch when a site wants the previous "install every auto_install" pass.

Open in Web Open in Cursor 

@cursor
cursor Bot merged commit d32cfcb into 20.0 Nov 12, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants