From 81e036cd4ad669f34230e8f918cc0791d9af1f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Fri, 3 Jul 2026 23:06:12 +0200 Subject: [PATCH] [FIX] finalize_db: only reset ``to upgrade`` modules, not ``to install`` The pre-shell state reset in ``scripts/finalize_db.sh`` forced both ``to upgrade`` and ``to install`` modules to ``installed``. Forcing ``to install`` to ``installed`` makes Odoo skip their install scripts entirely (tables, ``noupdate`` data, init hooks never run), leaving ghost "installed but empty" modules that the final ``-u all`` cannot recover. Restrict the reset to ``to upgrade`` only, whose real update is honored by the controlled ``-u all`` at the end of the script. Also drop the dead ``NOT IN (... state = 'uninstalled')`` sub-query: ``name`` is unique so a module never has two states, making the filter a no-op. A commented-out ``SELECT`` is added to trace pending-upgrade modules if the trailing ``-u all`` is ever removed. --- scripts/finalize_db.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/finalize_db.sh b/scripts/finalize_db.sh index c8d4cc9..f22397e 100755 --- a/scripts/finalize_db.sh +++ b/scripts/finalize_db.sh @@ -23,6 +23,24 @@ EOF ) query_postgres_container "$CLEANUP_SQL" "$DB_NAME" +# Reset modules still marked as 'to upgrade' before launching the Odoo shell +# scripts below. Loading the registry in `odoo shell` re-triggers the upgrade +# of these modules, which can fail on broken views (e.g. website_sale +# TypeError). The controlled `-u all` at the end of this script performs the +# real update afterwards. We deliberately do NOT touch 'to install' modules: +# forcing them to 'installed' would skip their install scripts entirely. +# +# Uncomment the SELECT below to trace which modules were pending upgrade +# before we neutralize their state (useful if the `-u all` above is removed). +# query_postgres_container " +# SELECT name FROM ir_module_module WHERE state = 'to upgrade' ORDER BY name; +# " "$DB_NAME" || true +query_postgres_container " +UPDATE ir_module_module +SET state = 'installed' +WHERE state = 'to upgrade'; +" "$DB_NAME" || true + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" PYTHON_SCRIPT="${SCRIPT_DIR}/lib/python/fix_duplicated_views.py" @@ -66,7 +84,7 @@ fi # Launch Odoo with database in finale version to run all updates -run_compose --debug run "$ODOO_SERVICE" -u all --log-level=debug --stop-after-init --no-http +run_compose --debug run "$ODOO_SERVICE" -u all --log-level=debug --stop-after-init --no-http --load=base,web,openupgrade_framework echo "" echo "Running post-migration view validation..."