Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] portal_backend: override load_menu as superuser to avoid person…
…alization restrictions closes #143 Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
- Loading branch information
1 parent
ed68ba1
commit a3c94c1
Showing
2 changed files
with
9 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
from odoo import models, Command | ||
|
||
from odoo import models, Command, tools | ||
|
||
class IrUiMenu(models.Model): | ||
_inherit = 'ir.ui.menu' | ||
|
||
@tools.ormcache_context('self._uid', 'debug', keys=('lang',)) | ||
def load_menus(self, debug): | ||
""" Assert all parent menus has internal group | ||
""" Assert all parent menus has internal group. | ||
""" | ||
parent_menus_wo_group = self.search([('parent_id', '=', False), ('groups_id', '=', False)]) | ||
parent_menus_wo_group.write({ | ||
# NOTE: | ||
# It is important to do it here to capture the case when portal_backend is already installed and the user | ||
# installs another module with a parent menu without internal group. | ||
parent_menus_wo_group = self.sudo().search([('parent_id', '=', False), ('groups_id', '=', False)]) | ||
parent_menus_wo_group.with_context('install_mode').write({ | ||
'groups_id': [Command.link(self.env.ref('base.group_user').id)] | ||
}) | ||
return super().load_menus(debug=debug) |