Skip to content
Merged
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
25 changes: 18 additions & 7 deletions addons/website/migrations/12.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from openupgradelib import openupgrade

from odoo.osv.expression import OR


def assign_theme(env):
theme_category = env.ref('base.module_category_theme')
Expand Down Expand Up @@ -46,15 +48,24 @@ def fill_website_socials(cr):


def sync_menu_views_pages_websites(env):
# Main menu and children must be website-agnostic
# Main menu, its children and unused website-specific root menus
# must be website-agnostic
all_websites = env["website"].search([])
main_menu = env.ref('website.main_menu')
child_menus = env["website.menu"].search([
("id", "child_of", main_menu.ids),
("website_id", "!=", False),
])
child_menus.write({"website_id": False})
wrongly_specific_menus = env["website.menu"].search(OR([
[
("id", "child_of", main_menu.ids),
("website_id", "!=", False),
],
[
("id", "not in", all_websites.mapped("menu_id").ids),
("website_id", "!=", False),
("parent_id", "=", False),
]
]))
wrongly_specific_menus.write({"website_id": False})
# Duplicate the main menu for all websites
for website in env["website"].search([]):
for website in all_websites:
website.copy_menu_hierarchy(main_menu)
# Find views that were website-specified in pre stage
old_metadata_col = openupgrade.get_legacy_name("bs4_migration_metadata")
Expand Down