This question has been flagged
2 Replies
25295 Views

Hi all,

I am trying to create a new menu based on a new module I am working on for Odoo v12.

I have "scaffolded" the module and using the scaffold struture.

The problem I found is that the menu structure is not shown on Odoo after module installed.

I have checked under Technical | Menu Items and they exist.

Also checked for the "action" and views and they also part of the database.

The code I used:

1. Module.py

class vehicles_brands(models.Model):
    _name='vehicles.brands'
    _description="Vehicle Brands"
    name = fields.Char(string="Brand", size=64, required=True)

2. Xml

<odoo>
  <data>   
<!-- TREE VIEW DEFINITION   -->
    <record model="ir.ui.view" id="vehicles.brands_tree_view">
      <field name="name">Vehicles</field>
      <field name="model">vehicles.brands</field>
      <field name="arch" type="xml">
        <tree>
          <field name="name"/>
        </tree>
      </field>
    </record>

    <!-- actions opening views on models -->
    <record model="ir.actions.act_window" id="vehicles.brands_action_window">
      <field name="name">Vehicle Brands</field>
      <field name="res_model">vehicles.brands</field>
      <field name="view_mode">tree,form</field>
    </record>

      <!-- Top menu item -->
    <menuitem name="Vehicles" id="vehicles.menu_root"/>
    <!-- Menu Category -->
    <menuitem name="Master Data" id="vehicles.data_menu" parent="vehicles.menu_root"/>
    <menuitem name="Brands" id="vehicles.brands_option" parent="vehicles.data_menu" action="vehicles.brands_action_window"/>
      </data>
</odoo>


I have no errors on the log and also confirm that the module is upgraded after every test.

What is wrong with this code?

PS: If I use the exact same code on Odoo 11 everything works fine.

Thank you in advance.


Avatar
Discard

Odoo Access Rights: https://goo.gl/8DZYRT

Author

Sehrish, thanks for the link. I have everything I need in this link. Regards

The menu is not visible as the access rights is not set, see this video to understand how to set access rights in odoo: https://www.youtube.com/watch?v=W5ya521uTlo&list=PLqRRLx0cl0hoJhjFWkFYowveq2Zn55dhM&index=7

Best Answer

Hi,

The reason why you are not seeing the menu is that you haven't given security/acessrights for the menu and model you have given.


Create a file named ir.model.acces.csv inside the security folder and define a rule for the model  vehicles.brands

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_vehicles_brands,access_vehicles_brands,model_vehicles_brands,base.group_user,1,1,1,0

Also, you give the groups="base.group_user" for the menus, this is just an example, you can set your permission accordingly.


In odoo11 where you say your code works fine, you can see the menu only when the admin is logged in. If any other user logged in the system, the same menu will not be visible. That is the case here in Odoo 12.

The admin users ID is not 1, to make menu visible give access rights to the menu and the model. Or you can see the menu after switching to superuser.



For switching to superuser, activate the developer mode and click the lady debugger button near the logged in users name in the top bar and click the Become Superuser option in the list. Once this is done, you can see the menu even without adding the security.


Different Reasons For A Menu Not Visible In Odoo


Thanks

Avatar
Discard
Author

Great Niyas. This exactly as you stated. This "superuser" option is new to me. Thank you very much.

Best Answer

Hello

You have to give access rights. Read, Write, Delete, Create permissions to your model

Avatar
Discard