콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
10412 화면

have created a custom menu for the sale order in my Odoo-12 website which is working properly.I just wanted to add the filter on displaying this menu only when the user is logged in.

Here is my code:

<odoo>
  <data noupdate="0">
    <record id="portal_sale_order_menu"model="website.menu">
      <field name="name">Sale Orders</field>
      <field name="url">/my/orders</field>
      <field name="sequence"type="int">1</field>
    </record>
  </data>
</odoo>

Can anyone help me out in this, I have referred many things but seems none of them have worked for me.

Any help is really appreciated.

Thanks!

아바타
취소
작성자

Hi Pouya Malekinejad,

Working of it seems fine by my method, I just want to hide or make invisible util and unless the user is logged in.

작성자 베스트 답변
<odoo>
  <data>
    <template id="custom_sign_in" customize_show="True" inherit_id="website.layout" name="Custom Sign In">
      <xpath expr="//ul[@id='top_menu']" position="replace">
        <ul class="nav navbar-nav ml-auto text-right" id="top_menu">
          <li class="nav-item" t-if="website.user_id != user_id">
            <a class="nav-link" role="menuitem" t-attf-href="/my/orders">
              <span>Sale Order</span>
            </a>
          </li>
          <li class="nav-item divider"></li>
          <li class="nav-item dropdown" t-if="website.user_id != user_id">
            <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">
              <b>
                <span t-esc="user_id.name"/>
              </b>
            </a>
            <div class="dropdown-menu js_usermenu" role="menu">
              <a href="/my/home" role="menuitem" class="dropdown-item">My Account</a>
              <a id="o_logout" class="dropdown-item" role="menuitem" href="/web/session/logout?redirect=/">Logout</a>
            </div>
          </li>
          <li class="nav-item" t-if="website.user_id == user_id">
            <a class="nav-link" href="/web/login">
              <b>Sign in</b>
            </a>
          </li>
        </ul>
      </xpath>
    </template>
  </data>
</odoo>
아바타
취소
베스트 답변

I'm not sure about showing, but for working, you can set it in your controller:

 
@http.route('/my/order', type='http', auth="user" # for requiring authentication
            website=True)
def my_order_menu(self, **post): 
return request.render('your_module_name.template')
 
아바타
취소
관련 게시물 답글 화면 활동
5
5월 19
8189
6
11월 18
8595
2
7월 25
6218
1
5월 25
10396
1
4월 24
3897