Skip to content
Open
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
17 changes: 7 additions & 10 deletions database_cleanup/wizards/purge_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# pylint: disable=consider-merging-classes-inherited
from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.fields import Command


class CleanupPurgeWizardMenu(models.TransientModel):
Expand All @@ -22,19 +23,15 @@ def find(self):
.with_context(active_test=False)
.search([("action", "!=", False)])
):
command = Command.create({"name": menu.complete_name, "menu_id": menu.id})
if not menu.action.exists():
# Menus may have actions that do not exist or have been deleted
res.append(command)
continue
if menu.action.type != "ir.actions.act_window":
continue
if menu.action.res_model and menu.action.res_model not in self.env:
res.append(
(
0,
0,
{
"name": menu.complete_name,
"menu_id": menu.id,
},
)
)
res.append(command)
if not res:
raise UserError(self.env._("No dangling menu entries found"))
return res
Expand Down
Loading