Skip to content

Commit 10cc07d

Browse files
committed
[FIX] pre-upgrade script to preserve module states during merges
1 parent bf90c9f commit 10cc07d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pre_upgrade_scripts/180_190/merge_and_renames.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,28 @@ def safe_new_module(cr, module, deps=(), *args, **kwargs):
3939
util_modules.new_module = original_new_module
4040

4141
for old, into in MERGE_MODULES:
42+
cr.execute(
43+
SQL(
44+
"""
45+
SELECT state FROM ir_module_module
46+
WHERE name = %(name)s
47+
""",
48+
name=old,
49+
)
50+
)
51+
old_state = cr.fetchone()
52+
old_state = old_state and old_state[0] or "uninstalled"
4253
util.merge_module(cr, old, into, update_dependers=False)
4354
# Ensure the target module is marked for upgrade
4455
cr.execute(
4556
SQL(
4657
"""
4758
UPDATE ir_module_module
48-
SET state = 'to upgrade'
49-
WHERE name = %(name)s
50-
AND state NOT IN ('installed', 'to install', 'to upgrade')
59+
SET state = %(upgrade_state)s
60+
WHERE name = %(name)s
5161
""",
5262
name=into,
63+
upgrade_state=old_state,
5364
)
5465
)
5566
for old, into in RENAMED_MODULES:

0 commit comments

Comments
 (0)