From 1beb458ffac39daab260c125cfaccd48ad35e4fc Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Mon, 25 Aug 2025 11:10:30 +0200 Subject: [PATCH] [OU-ADD] web_editor: Move custom assets --- .../web_editor/17.0.1.0/post-migration.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 openupgrade_scripts/scripts/web_editor/17.0.1.0/post-migration.py diff --git a/openupgrade_scripts/scripts/web_editor/17.0.1.0/post-migration.py b/openupgrade_scripts/scripts/web_editor/17.0.1.0/post-migration.py new file mode 100644 index 000000000000..c540f18e7362 --- /dev/null +++ b/openupgrade_scripts/scripts/web_editor/17.0.1.0/post-migration.py @@ -0,0 +1,17 @@ +from openupgradelib import openupgrade + + +def convert_assets(env): + for asset in env["ir.asset"].search([("path", "like", ".custom.")]): + path_1, extra = asset.path.split(".custom.", 1) + bundle_1, bundle_2, path_2 = extra.split(".", 2) + path = f"{path_1}.{path_2}" + bundle = f"{bundle_1}.{bundle_2}" + new_path = f"/_custom/{bundle}{path}" + env["ir.attachment"].search([("url", "=", asset.path)]).write({"url": new_path}) + asset.write({"path": new_path}) + + +@openupgrade.migrate() +def migrate(env, version): + convert_assets(env)