Menuitem in Openerp

If you have a menu but it hasn't a submenu with a valid action, OpenERP doesn't show it.
You must create a main menu (the main that appears in the top bar menu), a section main menu (the violet menu in the section) and a valid menu (the real clickable menu):

<menuitem id="main_menu" name="Main"/>
    <menuitem id="section_main_menu" parent="main_menu" sequence="450"/>
    <menuitem id="real_menu" parent="section_main_menu" action="your_action"/>



I recommend assigning actions to the lowest menu level only.

The menuitem tag for xml views is used to create all menues on any hierarchy level. The actual hierarchy is controlled by the parent attribute.


The sequence gives the order for your menu items (low to high), 'Settings' menu got sequence 500, 'Reporting' menu got sequence 170
By Default sequence=10

For submenues you can use the parent attribute inside the menu tag: e.g. parent="menu_hr_root". If you leave this attribute your menu item will be at the very top

To manage the visibility for your menu item, you can use the groups attribute inside the menu tag: e.g. groups="base.group_user".
If you leave the groups attribute the menuitem will be visible to everyone .

NOte :Note :Access Rights need to be defined in csv file for that object.

To place a Menu under Other Module menus you need to include the Parent module in your __openerp__.py file and give the parent menu id in your menu item. Let me explain you with an Example. Consider a model called Test. To make that Module visible under Human Resources module do the following steps:

Step-1: in __openerp__.py add the following line "depends" : ["hr"],

Step-2: then in your view xml file add the following lines Line-1: <menuitem id="menu_test" parent="hr.menu_hr_root" name="Test Module Parent"/> Line-2: <menuitem id="menu_test_child" parent="menu_test" name="My Menu" action="action_test"/>

Here **parent="hr.menu_hr_root"** denotes the parent id under which you are going to place your menu.  i.e., hr.menu_hr_root is the id of the Human Resource menu. And **name="Test Module Parent"** denotes your Test menu's parent name and it can be anything.
The Line-2 denotes your clickable menu. Here the **action="action_test"** denotes the action to be carried out when you click on My Menu.

menu entries are stored as records of the 'ir.ui.menu' object type, so it is possible to use 'record' XML tags to update 'ir.ui.menu' records by providing 'model' and 'id' attributes to identify the existing record.


Overriding A menuitem

If we want to change the name of the alraedy existing menu then we can  do this is declaring a new menuitem with the same ID of the menuitem you want to change.

        <record model="ir.ui.menu" id="mod_id.menu_id">
          <field name="name">My New Menu Name</field>

<!-- Use the special many2many value syntax to add a child record, and the `ref()` method to resolve the group XML ID -->

<field name="groups_id" eval="[(4,ref('my_new_group_id'))]"/>

        </record>


Deleting the Menuitem :

<delete id="base.menu_crm_case_job_req_main" model="ir.ui.menu"/>

0 comments:

Copyright © 2013 SoftKul