コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
10386 ビュー

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
8180
6
11月 18
8581
2
7月 25
6202
1
5月 25
10382
1
4月 24
3703