Skip to content

Commit 5e1aa62

Browse files
author
Pedro M. Baeza
authored
Merge pull request OCA#5346 from dixmit/17.0-assets
[17.0][OU-ADD] web_editor: Migration scripts for 17.0
2 parents ea06db6 + 1beb458 commit 5e1aa62

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from openupgradelib import openupgrade
2+
3+
4+
def convert_assets(env):
5+
for asset in env["ir.asset"].search([("path", "like", ".custom.")]):
6+
path_1, extra = asset.path.split(".custom.", 1)
7+
bundle_1, bundle_2, path_2 = extra.split(".", 2)
8+
path = f"{path_1}.{path_2}"
9+
bundle = f"{bundle_1}.{bundle_2}"
10+
new_path = f"/_custom/{bundle}{path}"
11+
env["ir.attachment"].search([("url", "=", asset.path)]).write({"url": new_path})
12+
asset.write({"path": new_path})
13+
14+
15+
@openupgrade.migrate()
16+
def migrate(env, version):
17+
convert_assets(env)

0 commit comments

Comments
 (0)