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

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.


아바타
취소

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

작성자

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

베스트 답변

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

아바타
취소
작성자

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

베스트 답변

Hello

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

아바타
취소
관련 게시물 답글 화면 활동
0
12월 24
1160
4
10월 19
33959
1
4월 17
3975
2
3월 15
7385
2
1월 24
13923