Skip to content

Commit

Permalink
[OU-ADD] website: BS4 to BS5 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
duong77476-viindoo committed Jul 11, 2023
1 parent 71e8a03 commit e428dc8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions openupgrade_scripts/scripts/website/16.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from itertools import chain

from openupgradelib import openupgrade
from openupgradelib.openupgrade_160 import convert_string_bootstrap_4to5

_xmlids_renames = [
(
Expand Down Expand Up @@ -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)
Expand All @@ -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)

0 comments on commit e428dc8

Please sign in to comment.