-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
16.0[IMP]document_page: menu_parent_id context domain of menu creation
- Loading branch information
Showing
5 changed files
with
47 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
from . import document_page | ||
from . import document_page_history | ||
from . import ir_ui_menu |
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,27 @@ | ||
# Copyright 2024 Alberto Martínez <alberto.martinez@sygel.es> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class IrUiMenu(models.Model): | ||
_inherit = "ir.ui.menu" | ||
|
||
def _visible_menu_ids(self, debug=False): | ||
visible_ids = super()._visible_menu_ids(debug) | ||
if self._context.get("ir.ui.menu.authorized_list"): | ||
# Add the authorized by groups menus that does not have an action | ||
menus = ( | ||
self.with_context(**{"ir.ui.menu.full_list": True}).search([]).sudo() | ||
) | ||
groups = ( | ||
self.env.user.groups_id | ||
if not debug | ||
else self.env.user.groups_id - self.env.ref("base.group_no_one") | ||
) | ||
authorized_menus = menus.filtered( | ||
lambda m: not m.groups_id or m.groups_id and groups | ||
) | ||
authorized_folder_menus = authorized_menus.filtered(lambda m: not m.action) | ||
visible_ids = visible_ids.union(authorized_folder_menus.ids) | ||
return visible_ids |
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