Skip to content

Commit 8d25062

Browse files
committed
[FIX] util.rename_xmlid: handle menu items
When renaming the xmlid of a (root) menu, we should also adapt it in the `homemenu_config` of users. This field contains a JSON array[^1] of the xmlids of menus in the order they should appear on the user home page. [^1]: in db, it is actually re-encoded as a JSON string representing the JSON array. closes #109 Related: odoo/upgrade#6225 Signed-off-by: Alvaro Fuentes Suarez (afu) <[email protected]>
1 parent 5df4bbe commit 8d25062

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/util/records.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,14 @@ def rename_xmlid(cr, old, new, noupdate=None, on_collision="fail"):
749749
# Don't change the view keys inconditionally to avoid changing unrelated views.
750750
cr.execute("UPDATE ir_ui_view SET key = %s WHERE key = %s", [new, old])
751751

752+
if model == "ir.ui.menu" and column_exists(cr, "res_users_settings", "homemenu_config"):
753+
query = """
754+
UPDATE res_users_settings
755+
SET homemenu_config = regexp_replace(homemenu_config::text, %(old)s, %(new)s)::jsonb
756+
WHERE homemenu_config::text ~ %(old)s
757+
"""
758+
cr.execute(query, {"old": r"\y{}\y".format(re.escape(old)), "new": new})
759+
752760
for parent_model, inh in direct_inherit_parents(cr, model):
753761
if inh.via:
754762
parent = parent_model.replace(".", "_")

0 commit comments

Comments
 (0)