Skip to content

Commit 4d9d8b1

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

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

pre_upgrade_scripts/180_190/merge_and_renames.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,27 @@ 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')
5149
""",
52-
name=into,
50+
name=old,
5351
)
5452
)
53+
old_state = cr.fetchone()
54+
if old_state:
55+
old_state = old_state[0]
56+
cr.execute(
57+
SQL(
58+
"""
59+
UPDATE ir_module_module
60+
SET state = %(upgrade_state)s
61+
WHERE name = %(name)s
62+
AND state NOT IN ('installed', 'to install', 'to upgrade')
63+
""",
64+
name=into,
65+
upgrade_state=old_state,
66+
)
67+
)
5568
for old, into in RENAMED_MODULES:
5669
util.rename_module(cr, old, into)
5770
for old, into in RENAMED_XMLIDS:

0 commit comments

Comments
 (0)