Skip to content

Commit

Permalink
[MIG] website_slides: migrate 15 to 16
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenvietlam0640 committed Jul 10, 2023
1 parent 84fa166 commit 35b93d0
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docsource/modules150-160.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
102 changes: 102 additions & 0 deletions openupgrade_scripts/scripts/website_slides/16.0.2.6/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from openupgradelib import openupgrade

renamed_fields = [
("slide.slide", "slide_slide", "datas", "binary_content"),
]

xml_ids_to_delete = [
"website_slides.rule_slide_slide_resource_manager",
]


def create_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 = 'document'
""",
)


def create_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 = 'local_file'
""",
)


def create_slide_type(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE slide_slide
ADD COLUMN IF NOT EXISTS slide_type varchar
""",
)

openupgrade.logged_query(
env.cr,
"""
UPDATE slide_slide
SET slide_type = 'pdf'
""",
)


def create_link(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE slide_slide_resource
ADD COLUMN IF NOT EXISTS link varchar
""",
)


def create_resource_type(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE slide_slide_resource
ADD COLUMN IF NOT EXISTS resource_type varchar
""",
)

openupgrade.logged_query(
env.cr,
"""
UPDATE slide_slide_resource
SET resource_type = 'file'
""",
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_fields(env, renamed_fields)
openupgrade.delete_records_safely_by_xml_id(env, xml_ids_to_delete)
create_slide_category(env)
create_source_type(env)
create_slide_type(env)
create_link(env)
create_resource_type(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---Models in module 'website_slides'---
obsolete model slide.slide.link

# NOTHING TO DO

---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
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

# NOTHING TO DO: executed by ORM

website_slides / slide.slide / binary_content (binary) : NEW attachment: True
website_slides / slide.slide / datas (binary) : DEL attachment: True

# DONE: renamed 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

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: create column and set default = 'document' 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']')

# DONE: set slide_type = 'pdf' because slide_category = 'document' and source_type = 'local_file'

website_slides / slide.slide / source_type (selection) : NEW required, selection_keys: ['external', 'local_file'], hasdefault: default

# DONE: create column and set default = 'local_file' 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

# NOTHING TO DO

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 columns 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
NEW ir.rule: website_slides.rule_slide_slide_resource_downloadable_manager (noupdate)

# NOTHING TO DO

DEL ir.rule: website_slides.rule_slide_slide_resource_manager (noupdate)

# DONE: delete safely 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

0 comments on commit 35b93d0

Please sign in to comment.