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.
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 9 25
|
302 | ||
Can't delete website
Đã xử lý
|
|
5
thg 8 25
|
4913 | |
|
2
thg 8 25
|
1566 | ||
|
5
thg 8 25
|
10222 | ||
Carrusel en sitios web
Đã xử lý
|
|
2
thg 7 25
|
1171 |