From d73dac2dc3672fa9201aee11806f115f52f56d64 Mon Sep 17 00:00:00 2001 From: Pilar Vargas Date: Thu, 11 Jun 2026 07:29:12 +0200 Subject: [PATCH] [OU-IMP] website: fix migrated snippets Add missing data-vcss="001" and data-vxml="001" attributes required by Odoo 18 on migrated snippets. TT63052 --- .../website/18.0.1.0/post-migration.py | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 openupgrade_scripts/scripts/website/18.0.1.0/post-migration.py diff --git a/openupgrade_scripts/scripts/website/18.0.1.0/post-migration.py b/openupgrade_scripts/scripts/website/18.0.1.0/post-migration.py new file mode 100644 index 000000000000..84e16ca80c08 --- /dev/null +++ b/openupgrade_scripts/scripts/website/18.0.1.0/post-migration.py @@ -0,0 +1,73 @@ +# Copyright 2026 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + + +def migrate_snippet_attribute(env, snippet_class, attribute, value): + openupgrade.logged_query( + env.cr, + rf""" + UPDATE ir_ui_view v + SET arch_db = data.arch_db + FROM ( + SELECT view.id, + jsonb_object_agg( + lang, + regexp_replace( + arch, + $$]*class="[^"]*{snippet_class}[^"]*")(?![^>]*{attribute}=)([^>]*)>$$, + $$$$, + 'g' + ) + ) AS arch_db + FROM ir_ui_view view + CROSS JOIN LATERAL jsonb_each_text(view.arch_db) AS value(lang, arch) + WHERE view.website_id IS NOT NULL + AND view.arch_db::text LIKE '%{snippet_class}%' + GROUP BY view.id + ) data + WHERE v.id = data.id + """, + ) + + +def migrate_s_comparisons_snippets(env): + openupgrade.logged_query( + env.cr, + r""" + UPDATE ir_ui_view v + SET arch_db = data.arch_db + FROM ( + SELECT view.id, + jsonb_object_agg( + lang, + regexp_replace( + regexp_replace( + arch, + $$]*class="[^"]*s_comparisons[^"]*")(?![^>]*data-vxml=)([^>]*)>$$, + $$$$, + 'g' + ), + $$]*class="[^"]*s_comparisons[^"]*")(?![^>]*data-vcss=)([^>]*)>$$, + $$$$, + 'g' + ) + ) AS arch_db + FROM ir_ui_view view + CROSS JOIN LATERAL jsonb_each_text(view.arch_db) AS value(lang, arch) + WHERE view.website_id IS NOT NULL + AND view.arch_db::text LIKE '%s_comparisons%' + GROUP BY view.id + ) data + WHERE v.id = data.id + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + migrate_snippet_attribute(env, "s_carousel_wrapper", "data-vcss", "001") + migrate_snippet_attribute(env, "s_three_columns", "data-vxml", "001") + migrate_snippet_attribute(env, "s_features_grid", "data-vcss", "001") + migrate_s_comparisons_snippets(env)