Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odgovori
10396 Prikazi

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!

Avatar
Opusti
Avtor

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.

Avtor Best Answer
<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>
Avatar
Opusti
Best Answer

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')
 
Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
5
maj 19
8182
6
nov. 18
8584
2
jul. 25
6207
1
maj 25
10387
1
apr. 24
3744