From c938c82edbdd65d0c8a3d818efa4fc798e99b020 Mon Sep 17 00:00:00 2001 From: nguyenvietlam0640 Date: Thu, 6 Jul 2023 16:57:28 +0700 Subject: [PATCH] [MIG] website_slides: migrate 15 to 16 --- docsource/modules150-160.rst | 2 +- .../website_slides/16.0.2.6/post-migration.py | 6 + .../website_slides/16.0.2.6/pre-migration.py | 106 ++++++++++++++ .../16.0.2.6/upgrade_analysis_work.txt | 131 ++++++++++++++++++ 4 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/website_slides/16.0.2.6/post-migration.py create mode 100644 openupgrade_scripts/scripts/website_slides/16.0.2.6/pre-migration.py create mode 100644 openupgrade_scripts/scripts/website_slides/16.0.2.6/upgrade_analysis_work.txt diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index 05d197d79d75..db4a679c199c 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -924,7 +924,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | website_sale_wishlist | |No DB layout changes. | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| website_slides | | | +| website_slides | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ | website_slides_forum | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/website_slides/16.0.2.6/post-migration.py b/openupgrade_scripts/scripts/website_slides/16.0.2.6/post-migration.py new file mode 100644 index 000000000000..a6974c761b81 --- /dev/null +++ b/openupgrade_scripts/scripts/website_slides/16.0.2.6/post-migration.py @@ -0,0 +1,6 @@ +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.load_data(env.cr, "website_slides", "16.0.2.6/noupdate_changes.xml") diff --git a/openupgrade_scripts/scripts/website_slides/16.0.2.6/pre-migration.py b/openupgrade_scripts/scripts/website_slides/16.0.2.6/pre-migration.py new file mode 100644 index 000000000000..9ed9c2801bce --- /dev/null +++ b/openupgrade_scripts/scripts/website_slides/16.0.2.6/pre-migration.py @@ -0,0 +1,106 @@ +from openupgradelib import openupgrade + +renamed_fields = [ + ("slide.slide", "slide_slide", "datas", "binary_content"), + ("slide.channel", "slide_channel", "share_template_id", "share_slide_template_id"), +] + +xml_ids_to_rename = [ + ( + "website_slides.rule_slide_slide_resource_manager", + "website_slides.rule_slide_slide_resource_downloadable_manager", + ), +] + +# slide_slide + + +def create_and_fill_data_from_slide_type_to_slide_category(env): + openupgrade.logged_query( + env.cr, + """ + ALTER TABLE slide_slide + ADD COLUMN IF NOT EXISTS slide_category VARCHAR + """, + ) + + openupgrade.logged_query( + env.cr, + """ + UPDATE slide_slide + SET slide_category = CASE + WHEN slide_type = 'webpage' THEN 'article' + WHEN slide_type = 'presentation' THEN 'document' + ELSE slide_type + END + """, + ) + + +def create_and_fill_data_for_source_type(env): + openupgrade.logged_query( + env.cr, + """ + ALTER TABLE slide_slide + ADD COLUMN IF NOT EXISTS source_type VARCHAR + """, + ) + + openupgrade.logged_query( + env.cr, + """ + UPDATE slide_slide + SET source_type = CASE + WHEN url IS NOT NULL AND slide_category = 'document' THEN 'external' + ELSE 'local_file' + END + """, + ) + +# slide_slide_resource + + +def create_column_and_migrate_data_from_slide_link_to_slide_resource(env): + openupgrade.logged_query( + env.cr, + """ + ALTER TABLE slide_slide_resource + ADD COLUMN IF NOT EXISTS link VARCHAR, + ADD COLUMN IF NOT EXISTS resource_type VARCHAR + """, + ) + + openupgrade.logged_query( + env.cr, + """ + UPDATE slide_slide_resource + SET resource_type = 'file' + """, + ) + + openupgrade.logged_query( + env.cr, + """ + INSERT INTO slide_slide_resource ( + name, + link, + slide_id, + resource_type + ) + SELECT + name, + link, + slide_id, + 'url' + FROM slide_slide_link + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.rename_fields(env, renamed_fields) + openupgrade.rename_xmlids(env.cr, xml_ids_to_rename) + create_and_fill_data_from_slide_type_to_slide_category(env) + create_column_and_migrate_data_from_slide_link_to_slide_resource(env) + create_and_fill_data_for_source_type(env) diff --git a/openupgrade_scripts/scripts/website_slides/16.0.2.6/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/website_slides/16.0.2.6/upgrade_analysis_work.txt new file mode 100644 index 000000000000..dd292c787a18 --- /dev/null +++ b/openupgrade_scripts/scripts/website_slides/16.0.2.6/upgrade_analysis_work.txt @@ -0,0 +1,131 @@ +---Models in module 'website_slides'--- +obsolete model slide.slide.link + +# DONE: move data from slide.slide.link to slide.slide.resource in pre-migration +# REASON: previously website_slides seperate slide.slide.link and slide.slide.resource one is store url another store file. Now combined into slide.slide.resource + +---Fields in module 'website_slides'--- +website_slides / slide.channel / cover_properties (text) : NEW hasdefault: default +website_slides / slide.channel / nbr_article (integer) : NEW isfunction: function, stored +website_slides / slide.channel / nbr_presentation (integer) : DEL +website_slides / slide.channel / nbr_webpage (integer) : DEL +website_slides / slide.channel / share_channel_template_id (many2one): NEW relation: mail.template, hasdefault: default + +# NOTHING TO DO: executed by ORM + +website_slides / slide.channel / share_slide_template_id (many2one): NEW relation: mail.template, hasdefault: default +website_slides / slide.channel / share_template_id (many2one) : DEL relation: mail.template +website_slides / slide.slide / binary_content (binary) : NEW attachment: True +website_slides / slide.slide / datas (binary) : DEL attachment: True + +# DONE: renamed fields in pre-migration + +website_slides / slide.slide / document_id (char) : DEL + +# NOTHING TO DO + +website_slides / slide.slide / embed_ids (one2many) : NEW relation: slide.embed +website_slides / slide.slide / embedcount_ids (one2many) : DEL relation: slide.embed + +# NOTHING TO DO: rename from embedcount_ids to embed_ids still one2many type + +website_slides / slide.slide / link_ids (one2many) : DEL relation: slide.slide.link +website_slides / slide.slide / mime_type (char) : DEL +website_slides / slide.slide / nbr_article (integer) : NEW isfunction: function, stored +website_slides / slide.slide / nbr_presentation (integer) : DEL +website_slides / slide.slide / nbr_webpage (integer) : DEL + +# NOTHING TO DO + +website_slides / slide.slide / slide_category (selection) : NEW required, selection_keys: ['article', 'document', 'infographic', 'quiz', 'video'], hasdefault: default + +# DONE: move value from old slide_type to slide_category in pre-migration + +website_slides / slide.slide / slide_type (selection) : selection_keys is now '['article', 'doc', 'google_drive_video', 'image', 'pdf', 'quiz', 'sheet', 'slides', 'vimeo_video', 'youtube_video']' ('['document', 'infographic', 'presentation', 'quiz', 'video', 'webpage']') + +# NOTHING TO DO: let ORM handle this section because this logic based on field video_source_type and this field computed by external library + +website_slides / slide.slide / source_type (selection) : NEW required, selection_keys: ['external', 'local_file'], hasdefault: default + +# DONE: create column and fill data in pre-migration + +website_slides / slide.slide.link / link (char) : DEL required +website_slides / slide.slide.link / name (char) : DEL required +website_slides / slide.slide.link / slide_id (many2one) : DEL relation: slide.slide, required +website_slides / slide.slide.resource / file_name (char) : NEW + +# NOTHING TO DO + +website_slides / slide.slide.resource / link (char) : NEW hasdefault: compute +website_slides / slide.slide.resource / resource_type (selection) : NEW required, selection_keys: ['file', 'url'] + +# DONE: create column and fill data in pre-migration + +---XML records in module 'website_slides'--- +NEW ir.actions.act_window: website_slides.action_slide_channel_pages_list +NEW ir.actions.act_window: website_slides.slide_channel_action_add +NEW ir.actions.act_window: website_slides.slide_embed_action +NEW ir.actions.act_window: website_slides.slide_slide_partner_action_from_slide +DEL ir.actions.act_window: website_slides.rating_rating_action_slide_channel_report +NEW ir.actions.act_window.view: website_slides.rating_rating_action_slide_channel_view_form +NEW ir.actions.act_window.view: website_slides.rating_rating_action_slide_channel_view_graph +NEW ir.actions.act_window.view: website_slides.rating_rating_action_slide_channel_view_kanban +NEW ir.actions.act_window.view: website_slides.rating_rating_action_slide_channel_view_pivot +NEW ir.actions.act_window.view: website_slides.rating_rating_action_slide_channel_view_tree +NEW ir.actions.act_window.view: website_slides.slide_channel_action_report_view_form +NEW ir.actions.act_window.view: website_slides.slide_channel_action_report_view_graph +NEW ir.actions.act_window.view: website_slides.slide_channel_action_report_view_pivot +NEW ir.actions.act_window.view: website_slides.slide_channel_action_report_view_tree +NEW ir.actions.act_window.view: website_slides.slide_slide_action_report_view_form +NEW ir.actions.act_window.view: website_slides.slide_slide_action_report_view_graph +NEW ir.actions.act_window.view: website_slides.slide_slide_action_report_view_pivot +NEW ir.actions.act_window.view: website_slides.slide_slide_action_report_view_tree +DEL ir.actions.act_window.view: website_slides.rating_rating_action_slide_channel_report_view_graph +DEL ir.actions.act_window.view: website_slides.rating_rating_action_slide_channel_report_view_pivot +DEL ir.actions.act_window.view: website_slides.rating_rating_action_slide_channel_report_view_tree + +# NOTHING TO DO + +DEL ir.model.access: website_slides.access_slide_slide_link_all +DEL ir.model.access: website_slides.access_slide_slide_link_officer + +# NOTHING TO DO + +NEW ir.model.constraint: website_slides.constraint_slide_channel_partner_channel_partner_uniq +NEW ir.model.constraint: website_slides.constraint_slide_channel_partner_check_completion +NEW ir.model.constraint: website_slides.constraint_slide_slide_partner_check_vote +NEW ir.model.constraint: website_slides.constraint_slide_slide_partner_slide_partner_uniq +NEW ir.model.constraint: website_slides.constraint_slide_slide_resource_check_file_type +NEW ir.model.constraint: website_slides.constraint_slide_slide_resource_check_url + +# NOTHING TO DO + + +NEW ir.rule: website_slides.rule_slide_slide_resource_downloadable_manager (noupdate) +DEL ir.rule: website_slides.rule_slide_slide_resource_manager (noupdate) + +# DONE: rename xmlid in pre-migration + +NEW ir.ui.menu: website_slides.menu_slide_channel_pages +DEL ir.ui.menu: website_slides.website_slides_menu_courses_reviews +NEW ir.ui.view: website_slides.course_join +NEW ir.ui.view: website_slides.rating_rating_view_form_slides +NEW ir.ui.view: website_slides.rating_rating_view_tree_slide_channel +NEW ir.ui.view: website_slides.slide_channel_pages_kanban_view +NEW ir.ui.view: website_slides.slide_channel_pages_tree_view +NEW ir.ui.view: website_slides.slide_channel_view_form_add +NEW ir.ui.view: website_slides.slide_channel_view_pivot +NEW ir.ui.view: website_slides.slide_embed_view_search +NEW ir.ui.view: website_slides.slide_embed_view_tree +NEW ir.ui.view: website_slides.slide_sidebar_done_button +NEW ir.ui.view: website_slides.slide_slide_partner_view_form +NEW ir.ui.view: website_slides.slide_slide_partner_view_search +NEW ir.ui.view: website_slides.slide_slide_partner_view_tree +NEW ir.ui.view: website_slides.slide_slide_view_tree_report +NEW ir.ui.view: website_slides.snippet_options +DEL ir.ui.view: website_slides.rating_rating_view_kanban_slide_channel +DEL ir.ui.view: website_slides.slide_edit_options +DEL ir.ui.view: website_slides.user_navbar_inherit_website_slides +NEW mail.template: website_slides.mail_template_channel_shared (noupdate) + +# NOTHING TO DO