From 016a4b040cff8c19357acbc6268e1df608b0bbb3 Mon Sep 17 00:00:00 2001 From: quyen Date: Fri, 30 Jun 2023 09:30:23 +0700 Subject: [PATCH] [MIG] website: migrate 15 to 16 --- docsource/modules150-160.rst | 2 +- .../website/16.0.1.0/post-migration.py | 6 ++ .../scripts/website/16.0.1.0/pre-migration.py | 62 ++++++++++++++ .../website/16.0.1.0/upgrade_analysis.txt | 2 +- .../16.0.1.0/upgrade_analysis_work.txt | 85 +++++++++++++++++++ 5 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 openupgrade_scripts/scripts/website/16.0.1.0/post-migration.py create mode 100644 openupgrade_scripts/scripts/website/16.0.1.0/pre-migration.py create mode 100644 openupgrade_scripts/scripts/website/16.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index 4bfa956a7f1b..f38186e746ea 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -800,7 +800,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | web_unsplash | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| website | | | +| website | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ | website_blog | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/website/16.0.1.0/post-migration.py b/openupgrade_scripts/scripts/website/16.0.1.0/post-migration.py new file mode 100644 index 000000000000..822f04cb2392 --- /dev/null +++ b/openupgrade_scripts/scripts/website/16.0.1.0/post-migration.py @@ -0,0 +1,6 @@ +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.delete_records_safely_by_xml_id(env, ["website.website_menu"]) 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 new file mode 100644 index 000000000000..4dfff21801e7 --- /dev/null +++ b/openupgrade_scripts/scripts/website/16.0.1.0/pre-migration.py @@ -0,0 +1,62 @@ +from openupgradelib import openupgrade + +_xmlids_renames = [ + ( + "website.group_website_publisher", + "website.group_website_restricted_editor", + ) +] + +# delete xml xpath for odoo add it again +_xmlids_delete = [ + "website.s_image_gallery_options", + "website.s_product_catalog_options", + "website.s_table_of_content_options", + "website.s_media_list_options", + "website.s_timeline_options", + "website.website_configurator", + "website.res_config_settings_view_form", +] + + +def _set_xml_ids_noupdate_value(env): + openupgrade.set_xml_ids_noupdate_value( + env, "website", ["action_website", "s_masonry_block_default_image_2"], False + ) + + +def _fill_partner_id_if_null(env): + openupgrade.logged_query( + env.cr, + """ + UPDATE website_visitor + SET partner_id = CASE + WHEN length(access_token) != 32 THEN CAST(access_token AS integer) + ELSE partner_id + END + WHERE partner_id IS NULL; + """, + ) + + +def _fill_language_ids_if_null(env): + openupgrade.logged_query( + env.cr, + """ + INSERT INTO website_lang_rel (website_id, lang_id) + SELECT w.id, rl.id + FROM website w + CROSS JOIN res_lang rl + WHERE w.id NOT IN (SELECT website_id FROM website_lang_rel) + AND rl.active = true; + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + _set_xml_ids_noupdate_value(env) + _fill_partner_id_if_null(env) + _fill_language_ids_if_null(env) + openupgrade.rename_xmlids(env.cr, _xmlids_renames) + openupgrade.delete_records_safely_by_xml_id(env, _xmlids_delete) diff --git a/openupgrade_scripts/scripts/website/16.0.1.0/upgrade_analysis.txt b/openupgrade_scripts/scripts/website/16.0.1.0/upgrade_analysis.txt index cc14faa6c8bf..d5d1bebecafb 100644 --- a/openupgrade_scripts/scripts/website/16.0.1.0/upgrade_analysis.txt +++ b/openupgrade_scripts/scripts/website/16.0.1.0/upgrade_analysis.txt @@ -77,6 +77,6 @@ DEL ir.ui.view: website.s_share_options DEL ir.ui.view: website.snippet_options_header_brand DEL ir.ui.view: website.user_navbar DEL ir.ui.view: website.website_configurator -DEL ir.ui.view: website.website_publisher +DEL ir.ui.view: website.website_publisherz NEW res.groups: website.group_website_restricted_editor DEL res.groups: website.group_website_publisher diff --git a/openupgrade_scripts/scripts/website/16.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/website/16.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..a61443626c81 --- /dev/null +++ b/openupgrade_scripts/scripts/website/16.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,85 @@ +---Models in module 'website'--- +---Fields in module 'website'--- +website / theme.website.menu / mega_menu_classes (char) : NEW +website / theme.website.menu / mega_menu_content (html) : NEW +website / theme.website.menu / use_main_menu_as_parent (boolean): NEW hasdefault: default +website / theme.website.page / footer_visible (boolean) : NEW hasdefault: default +website / theme.website.page / header_color (char) : NEW +website / theme.website.page / header_overlay (boolean) : NEW +website / theme.website.page / header_visible (boolean) : NEW hasdefault: default +website / theme.website.page / is_published (boolean) : NEW +website / website / country_group_ids (many2many) : DEL relation: res.country.group +website / website / google_management_client_id (char): DEL +website / website / google_management_client_secret (char): DEL +website / website / homepage_id (many2one) : DEL relation: website.page +website / website / homepage_url (char) : NEW +website / website / language_ids (many2many) : now required +# Fill language_ids if null +website / website / plausible_shared_key (char) : NEW +website / website / plausible_site (char) : NEW +website / website.menu / group_ids (many2many) : DEL relation: res.groups +website / website.page / cache_key_expr (char) : DEL +website / website.page / cache_time (integer) : DEL +website / website.visitor / _order : _order is now 'id DESC' ('last_connection_datetime DESC') +website / website.visitor / active (boolean) : DEL +website / website.visitor / name (char) : not stored anymore +website / website.visitor / name (char) : now related +website / website.visitor / partner_id (many2one) : now a function +# Fill partner id if null +---XML records in module 'website'--- +DEL ir.actions.act_url: website.start_configurator_act_url +NEW ir.actions.client: website.action_open_website_configurator +NEW ir.actions.client: website.website_configurator +NEW ir.actions.client: website.website_preview +NEW ir.actions.server: website.ir_actions_server_website_analytics +DEL ir.actions.server: website.ir_actions_server_website_google_analytics +NEW ir.asset: website.s_countdown_000_xml +NEW ir.asset: website.s_dynamic_snippet_000_xml +NEW ir.asset: website.s_dynamic_snippet_carousel_000_xml +NEW ir.asset: website.s_image_gallery_000_xml +NEW ir.asset: website.s_map_000_js +NEW ir.asset: website.s_process_steps_001_scss +NEW ir.asset: website.s_searchbar_000_xml +NEW ir.asset: website.s_social_media_000_scss +NEW ir.asset: website.s_website_form_xml +NEW ir.model.access: website.access_website_ir_ui_view_restricted_editor +DEL ir.model.access: website.access_website_ir_ui_view_publisher +NEW ir.model.constraint: website.constraint_website_domain_unique +DEL ir.model.constraint: website.constraint_website_visitor_partner_uniq +DEL ir.rule: website.website_menu (noupdate) +NEW ir.ui.menu: website.custom_menu_edit_menu +NEW ir.ui.menu: website.menu_ace_editor +NEW ir.ui.menu: website.menu_content +NEW ir.ui.menu: website.menu_current_page +NEW ir.ui.menu: website.menu_edit_menu +NEW ir.ui.menu: website.menu_optimize_seo +NEW ir.ui.menu: website.menu_page_properties +NEW ir.ui.menu: website.menu_reporting [renamed from website_sale module] +NEW ir.ui.menu: website.menu_site +NEW ir.ui.menu: website.menu_website_analytics +NEW ir.ui.menu: website.menu_website_preview +DEL ir.ui.menu: website.menu_dashboard +DEL ir.ui.menu: website.menu_visitor_sub_menu +DEL ir.ui.menu: website.menu_website_google_analytics +NEW ir.ui.view: website.404_plausible +NEW ir.ui.view: website.iframefallback +NEW ir.ui.view: website.neutralize_ribbon +NEW ir.ui.view: website.res_config_settings_view_form_inherit_auth_signup +NEW ir.ui.view: website.s_process_steps_options +NEW ir.ui.view: website.s_social_media +NEW ir.ui.view: website.s_social_media_options +NEW ir.ui.view: website.website_page_properties_view_form +NEW ir.ui.view: website.website_pages_kanban_view +DEL ir.ui.view: website.compiled_assets_wysiwyg +DEL ir.ui.view: website.index_management +DEL ir.ui.view: website.list_website_pages +DEL ir.ui.view: website.one_page_line +DEL ir.ui.view: website.publish_short +DEL ir.ui.view: website.s_share_options +DEL ir.ui.view: website.snippet_options_header_brand +DEL ir.ui.view: website.user_navbar +DEL ir.ui.view: website.website_configurator +DEL ir.ui.view: website.website_publisher +NEW res.groups: website.group_website_restricted_editor +DEL res.groups: website.group_website_publisher +# Rename Group