Skip to content

Commit c64a923

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

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

pre_upgrade_scripts/180_190/merge_and_renames.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,24 @@ def safe_new_module(cr, module, deps=(), *args, **kwargs):
4444
cr.execute(
4545
SQL(
4646
"""
47-
UPDATE ir_module_module
48-
SET state = 'to upgrade'
47+
SELECT state FROM ir_module_module
4948
WHERE name = %(name)s
50-
AND state NOT IN ('installed', 'to install', 'to upgrade')
49+
""",
50+
name=old,
51+
)
52+
)
53+
old_state = cr.fetchone()
54+
old_state = old_state and old_state[0] or "uninstalled"
55+
cr.execute(
56+
SQL(
57+
"""
58+
UPDATE ir_module_module
59+
SET state = %(upgrade_state)s
60+
WHERE name = %(name)s
61+
AND state NOT IN ('installed', 'to install', 'to upgrade')
5162
""",
5263
name=into,
64+
upgrade_state=old_state,
5365
)
5466
)
5567
for old, into in RENAMED_MODULES:

0 commit comments

Comments
 (0)