I see group_ids in website.menu but seems not work as portal and public user has access to website.menu model already
is there any solution to hide a website menu based on custom group?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
I see group_ids in website.menu but seems not work as portal and public user has access to website.menu model already
is there any solution to hide a website menu based on custom group?
Hi,
You can achieve it by inheriting the _compute_visible method of website.menu model.
Try any methods.
1- You can use the module,
* https://apps.odoo.com/apps/modules/17.0/website_menu_restriction
2- By inheriting the website.layout and add the user group.
< template
id="layout"
inherit_id="website.layout">
< xpath expr="//header/t[@t-cache]" position="attributes">
< attribute name="t-cache" add="website.get_website_user_group_cache_key()"/>
< /xpath>
< /template>
3- Inherit the website.menu model.
class WebsiteMenu(models.Model):
_inherit = 'website.menu'
def _compute_visible(self):
"""Compute menu invisible"""
super()._compute_visible()
for menu in self:
if not menu.is_visible:
return
if menu.name == 'Shop' and not self.env.user.user_has_groups(
'base.group_user'):
menu.is_visible = False
Hope it helps
Go to Website -> Configuration -> Menus, open the menu item in question and set Visible Groups to the groups you want it available for:
Results in
(not logged in)
(logged in)
Note: This hides the menu item only as asked. /blog is still accessible.
Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!
RekisteröidyAiheeseen liittyviä artikkeleita | Vastaukset | Näkymät | Toimenpide | |
---|---|---|---|---|
|
5
elok. 25
|
9961 | ||
Carrusel en sitios web
Ratkaistu
|
|
2
heinäk. 25
|
1022 | |
How to launch my website
Ratkaistu
|
|
4
kesäk. 25
|
1158 | |
|
1
kesäk. 25
|
1467 | ||
|
1
toukok. 25
|
1372 |