Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions openupgrade_scripts/apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@
# odoo
# OCA/...
}

# Modules dropped from the distribution. base pre-migration marks them
# ``to remove`` so Odoo uninstalls their views and assets.
removed_modules = [
# odoo/design-themes: snippets library removed in 20.0, not folded into website
"theme_common",
]
37 changes: 37 additions & 0 deletions openupgrade_scripts/scripts/base/20.0.1.3/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2026 Odoo Community Association (OCA)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

# pylint: disable=odoo-addons-relative-import
from odoo.addons.openupgrade_scripts.apriori import removed_modules


def _remove_obsolete_modules(env):
"""Mark modules that disappeared from the distribution as ``to remove``.

Odoo logs ``module <name>: manifest not found`` from ``button_upgrade``
(that runs before migration scripts) and would leave the row ``to upgrade``.
``base`` pre-migration moves the modules listed in ``apriori.removed_modules``
to ``to remove``. The end of the upgrade then calls ``module_uninstall``,
which deletes the module's views and assets and sets the state to
``uninstalled``. ``theme_common`` (design-themes) is the 20.0 case: the
snippets library was removed and was not merged into ``website``.
"""
if not removed_modules:
return
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_module_module
SET state = 'to remove'
WHERE name IN %s
AND state IN ('installed', 'to upgrade', 'to install')
""",
(tuple(removed_modules),),
)


@openupgrade.migrate()
def migrate(env, version):
_remove_obsolete_modules(env)
Loading