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..6b8a03f6b6d3 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.inherit_id IS NULL AND 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)