Repository navigation
[FIX] openupgrade_framework: auto-install only modules new in this version - #5
Merged
Merged
Conversation
…rsion Co-authored-by: André de Kock <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
On a database that started before Odoo 16 and was upgraded 16→17→18→19→20,
iaphad been uninstalled on purpose. Odoo 18 makesiapauto_install. OpenUpgrade'sIrModuleModule.update_listpatch callsbutton_install()on every uninstalled auto-install module whose dependencies are installed (exceptl10n_*).iapcomes back, and with itiap_mail,iap_crm,crm_iap_enrich,crm_iap_mine,partner_autocomplete,snailmailandsnailmail_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()createsir.module.modulerows 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.0only. The same change applies to OCA18.0and19.0(the 18.0/19.0 copies do not have the Odoo 20Domainfilter, but the snapshot logic is the same).Change
openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_module.pyir.module.module.namebefore calling the originalupdate_list.openupgrade_legacy_<major>_<minor>_ir_module_moduleas pre-existing.basepre-migration creates that table (SELECT name, state FROM ir_module_module), so a row that was deleted and recreated by a laterupdate_listis still recognised. Table names are matched with a full regex and quoted withpsycopg2.sql.Identifier.auto_install, with dependencies ininstalled/to upgrade/to install, and still excludingl10n_*and country-specific modules for countries the database does not use.IrModuleModule.update_list._original_methodis still resolved at run time, the same way the 18.0/19.0/20.0 patches do it.Opt out, restoring the old behaviour:
openupgrade_auto_install_existing = TrueOPENUPGRADE_AUTO_INSTALL_EXISTING=1Tests
test_03_update_listnow creates a module beforeupdate_listand asserts it stays uninstalled, and stubs_original_methodso a row created during the call becomesto install. A newl10n_*row created the same way stays uninstalled.test_04_update_list_install_existingsets the environment variable and asserts the pre-existing module is installed again.Not executed here (no Odoo test database).
ruffis clean on both files.Upstream
No open or merged OCA pull request changes this behaviour (the existing
update_listPRs, OCA#5167 and OCA#5337, only fix the return value and the decorator). Suitable for OCA18.0,19.0and20.0onceopenupgrade_frameworkis on20.0(OCA OCA#6046 / OCA#6068). The 20.0 file usesodoo.fields.Domain; 18.0 and 19.0 keep their list domains.Limitation
A module that is not in
ir.module.moduleand 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.