Skip to content

Commit d73dac2

Browse files
[OU-IMP] website: fix migrated snippets
Add missing data-vcss="001" and data-vxml="001" attributes required by Odoo 18 on migrated snippets. TT63052
1 parent 2ee4315 commit d73dac2

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright 2026 Tecnativa - Pilar Vargas
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from openupgradelib import openupgrade
5+
6+
7+
def migrate_snippet_attribute(env, snippet_class, attribute, value):
8+
openupgrade.logged_query(
9+
env.cr,
10+
rf"""
11+
UPDATE ir_ui_view v
12+
SET arch_db = data.arch_db
13+
FROM (
14+
SELECT view.id,
15+
jsonb_object_agg(
16+
lang,
17+
regexp_replace(
18+
arch,
19+
$$<section(?=[^>]*class="[^"]*{snippet_class}[^"]*")(?![^>]*{attribute}=)([^>]*)>$$,
20+
$$<section\1 {attribute}="{value}">$$,
21+
'g'
22+
)
23+
) AS arch_db
24+
FROM ir_ui_view view
25+
CROSS JOIN LATERAL jsonb_each_text(view.arch_db) AS value(lang, arch)
26+
WHERE view.website_id IS NOT NULL
27+
AND view.arch_db::text LIKE '%{snippet_class}%'
28+
GROUP BY view.id
29+
) data
30+
WHERE v.id = data.id
31+
""",
32+
)
33+
34+
35+
def migrate_s_comparisons_snippets(env):
36+
openupgrade.logged_query(
37+
env.cr,
38+
r"""
39+
UPDATE ir_ui_view v
40+
SET arch_db = data.arch_db
41+
FROM (
42+
SELECT view.id,
43+
jsonb_object_agg(
44+
lang,
45+
regexp_replace(
46+
regexp_replace(
47+
arch,
48+
$$<section(?=[^>]*class="[^"]*s_comparisons[^"]*")(?![^>]*data-vxml=)([^>]*)>$$,
49+
$$<section\1 data-vxml="001">$$,
50+
'g'
51+
),
52+
$$<section(?=[^>]*class="[^"]*s_comparisons[^"]*")(?![^>]*data-vcss=)([^>]*)>$$,
53+
$$<section\1 data-vcss="001">$$,
54+
'g'
55+
)
56+
) AS arch_db
57+
FROM ir_ui_view view
58+
CROSS JOIN LATERAL jsonb_each_text(view.arch_db) AS value(lang, arch)
59+
WHERE view.website_id IS NOT NULL
60+
AND view.arch_db::text LIKE '%s_comparisons%'
61+
GROUP BY view.id
62+
) data
63+
WHERE v.id = data.id
64+
""",
65+
)
66+
67+
68+
@openupgrade.migrate()
69+
def migrate(env, version):
70+
migrate_snippet_attribute(env, "s_carousel_wrapper", "data-vcss", "001")
71+
migrate_snippet_attribute(env, "s_three_columns", "data-vxml", "001")
72+
migrate_snippet_attribute(env, "s_features_grid", "data-vcss", "001")
73+
migrate_s_comparisons_snippets(env)

0 commit comments

Comments
 (0)