Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][MIG] website #2840

Merged
merged 2 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docsource/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|web_unsplash | |
+--------------------------------------------+-------------------------------------------------+
|website | |
|website | Done |
+--------------------------------------------+-------------------------------------------------+
|website_blog | |
+--------------------------------------------+-------------------------------------------------+
Expand Down Expand Up @@ -778,7 +778,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|website_sms | |
+--------------------------------------------+-------------------------------------------------+
| |del| website_theme_install | Merged into website |
| |del| website_theme_install | Done. Merged into website |
+--------------------------------------------+-------------------------------------------------+
|website_twitter | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
6 changes: 4 additions & 2 deletions openupgrade_scripts/apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@
# OCA/project
"project_description": "project",
"project_stage_closed": "project",
# OCA/web
"web_editor_background_color": "web_editor",
# OCA/survey
"survey_description": "survey",
# OCA/web
"web_editor_background_color": "web_editor",
# OCA/website
"website_cookie_notice": "website",
# OCA/...
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<field name="action_id" ref="action_website_edit"/>
</record>
<record id="business_conference" model="ir.attachment">
<field name="datas" type="base64" file="website/static/src/img/library/business_conference.jpg"/>
<!-- <field name="datas" type="base64" file="website/static/src/img/library/business_conference.jpg"/>-->
<field name="type">url</field>
<field name="url">/website/static/src/img/library/business_conference.jpg</field>
</record>
Expand Down
32 changes: 32 additions & 0 deletions openupgrade_scripts/scripts/website/14.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


def website_cookie_notice_post_migration(env):
cookie_message = env.ref("website.cookie_message", raise_if_not_found=False)
if cookie_message:
websites = env["website"].search([])
websites.write({"cookies_bar": True})
env.cr.execute(
"""WITH keys AS (
SELECT key
FROM ir_ui_view iuv
JOIN ir_model_data imd ON (imd.model = 'ir.ui.view'
AND imd.res_id = iuv.id AND module = 'website')
WHERE imd.name IN ('cookie_message', 'cookie_message_container')
)
SELECT iuv.id
FROM ir_ui_view iuv
JOIN keys ON iuv.key = keys.key""",
)
view_ids = [x[0] for x in env.cr.fetchall()]
if view_ids:
env["ir.ui.view"].browse(view_ids).unlink()


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env.cr, "website", "14.0.1.0/noupdate_changes.xml")
openupgrade.delete_records_safely_by_xml_id(env, ["website.aboutus_page"])
website_cookie_notice_post_migration(env)
57 changes: 57 additions & 0 deletions openupgrade_scripts/scripts/website/14.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


def assure_website_visitor_partner_is_set(env):
openupgrade.logged_query(
env.cr,
"""
UPDATE website_visitor wv
SET partner_id = rel.partner_id
FROM website_visitor_partner_rel rel
WHERE wv.partner_id IS NULL AND wv.id = rel.visitor_id""",
)


def website_cookie_notice_pre_migration(env):
openupgrade.logged_query(
env.cr,
"""
WITH keys AS (
SELECT key
FROM ir_ui_view iuv
JOIN ir_model_data imd ON (
imd.model = 'ir.ui.view' AND imd.res_id = iuv.id AND module = 'website')
WHERE imd.name IN ('legal_cookie_policy', 'cookie_banner')
)
DELETE FROM ir_ui_view iuv
USING keys
WHERE iuv.key = keys.key AND iuv.website_id IS NOT NULL""",
)
# rename xmlids
openupgrade.rename_xmlids(
env.cr,
[
("website.legal_cookie_policy", "website.cookie_policy"),
("website.cookie_banner", "website.cookies_bar"),
],
)


@openupgrade.migrate()
def migrate(env, version):
assure_website_visitor_partner_is_set(env)
openupgrade.set_xml_ids_noupdate_value(
env,
"website",
[
"website_designer_edit_qweb",
"website_designer_view",
"website_group_system_edit_all_views",
"website_menu",
"website_page_rule_public",
],
True,
)
website_cookie_notice_pre_migration(env)
Loading