-
-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2840 from ForgeFlow/14.0-mig-website
[14.0][MIG] website
- Loading branch information
Showing
6 changed files
with
424 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
openupgrade_scripts/scripts/website/14.0.1.0/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
57
openupgrade_scripts/scripts/website/14.0.1.0/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.