From c8b9dcb6f5e2c06cfbe3c2d3e8b9323462b944cf Mon Sep 17 00:00:00 2001 From: duongnguyen Date: Tue, 11 Jul 2023 14:37:38 +0700 Subject: [PATCH] [OU-ADD] website: BS4 to BS5 migration --- .../scripts/website/16.0.1.0/pre-migration.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/openupgrade_scripts/scripts/website/16.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/website/16.0.1.0/pre-migration.py index adbb47648c1c..ea94e2b4a721 100644 --- a/openupgrade_scripts/scripts/website/16.0.1.0/pre-migration.py +++ b/openupgrade_scripts/scripts/website/16.0.1.0/pre-migration.py @@ -1,4 +1,7 @@ +from itertools import chain + from openupgradelib import openupgrade +from openupgradelib.openupgrade_160 import convert_string_bootstrap_4to5 _xmlids_renames = [ ( @@ -70,6 +73,22 @@ def keep_the_first_domain_when_duplicate(env): ) +def boostrap_5_migration(env): + """Convert customized website views to Bootstrap 5.""" + # Find views to convert + env.cr.execute( + """ + SELECT iuv.id FROM ir_ui_view iuv JOIN website w on w.id = iuv.website_id + WHERE iuv.type = 'qweb' AND iuv.website_id IS NOT NULL + """ + ) + view_ids = list(chain.from_iterable(env.cr.fetchall())) + all_view_need_bs5_migration = env["ir.ui.view"].browse(view_ids) + for view in all_view_need_bs5_migration: + new_arch = convert_string_bootstrap_4to5(view.arch_db) + view.arch_db = new_arch + + @openupgrade.migrate() def migrate(env, version): _fill_partner_id_if_null(env) @@ -78,3 +97,4 @@ def migrate(env, version): openupgrade.delete_records_safely_by_xml_id(env, _xmlids_delete) delete_constraint_website_visitor_partner_uniq(env) keep_the_first_domain_when_duplicate(env) + boostrap_5_migration(env)