Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
12529 มุมมอง

Hello there,
I had to recreate the public user in one server.

How could I hide this menu item public user - AS when nobody is logged on the website?

Thanks to help. 

อวตาร
ละทิ้ง

use record rule perhaps?

คำตอบที่ดีที่สุด

https://youtu.be/zHPtb1SR8Sk

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

you can try this module 

https://github.com/OCA/website/blob/9.0/website_menu_by_user_status


in short just check  request.uid == %(base.public_user)d



<t-if="request.uid == %(base.public_user)d)"> put you code here </t>

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

This I found to work in odoo V12.

<template id="search_directory"name="Online Directory Search"inherit_id="portal.frontend_layout">	​    <xpathexpr="//ul[@id='top_menu']/li[1]"position="after"><ahref="/search"role="menuitem"groups="base.group_user,online_directory.od_basic_search"class="nav-link">Online Directorya>
xpath>
template>
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You can set groups (internal user & portal user) for the website menu in order to hide the menu for public user when not logged in.

Example:

name="group_ids" eval="[(4, ref('base.group_user')), (4, ref('base.group_portal'))]"

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Our answer. hanks everybody.


<template id="layout_iv" inherit_id="website.layout" >

<xpath expr="//li[@class='dropdown']" position="replace">

<t t-if="request.uid != %(base.public_user)d">

<li class="divider" t-ignore="true" t-if="website.user_id != user_id"/>

<li class="dropdown" t-ignore="true" t-if="website.user_id != user_id">

<a href="#" class="dropdown-toggle" data-toggle="dropdown">

<b>

<span t-esc="user_id.name"/>

<span class="caret"></span>

</b>

</a>

<ul class="dropdown-menu js_usermenu" role="menu">

<li><a href="/web" role="menuitem">My Account</a></li>

<li class="divider"/>

<li><a t-attf-href="/web/session/logout?redirect=/" role="menuitem">Logout</a></li>

</ul>

</li>

</t>

</xpath>

</template>

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
how to get the logged user แก้ไขแล้ว
2
ก.พ. 24
14034
1
ก.พ. 16
4449
1
ส.ค. 15
7087
4
ม.ค. 23
25916
3
ธ.ค. 22
6760