Skip to Content
Menu
This question has been flagged
17 Replies
103894 Views

hello everyone , i'm trying to add a new menuitem on my created module , and have no idea how to do so ... Can anyone give me any hints or any exemples ...

my module is working fine , in the menu on the left side i want to add a new link if i may say so .. pleaase help me

Avatar
Discard

wanna add directly into system or from code , plz describe

Author

i want to add it using code .

I would like to add a button directly from system - how can I do that? I cannot find these sections when editing FormView, thank you!

Best Answer
<menuitem id="my_menu_id" name="My Menu"
        parent="parent_menu_id" sequence="1"/>
Avatar
Discard
Author

thank you very much it did work , now to add an action to this new menuitem , i create a new form, new tree and stuff like the first one ??

Best Answer

In your view definition xml file your_module_view.xml add the following code (you may want to change some parameters into yours):

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- Your List View Definition -->
<record id="view_your_model_name_tree" model="ir.ui.view">
    <field name="name">Your.Module.Name_tree</field>
    <field name="model">your.object</field>
    <field name="arch" type="xml">
        <tree string="ANY NAME">
            <!-- Add All Fields You Want In The List Here -->
            <field name="db_field_name"/>
        </tree>
    </field>
</record>

<!-- Your Form View Definition -->
<record id="view_your_model_name_form" model="ir.ui.view">
    <field name="name">Your.Module.Name_form</field>
    <field name="model">your.object</field>
    <field name="arch" type="xml">
        <form string="Form View Name" version="7.0">
            <!-- Add All Fields You Want In The Form Here -->
            <field name="db_field_name"/>
        </form>
    </field>
</record>

<!-- Your Action Window Definition -->
<record id="action_123" model="ir.actions.act_window">
    <field name="name">Your Module Name</field>
    <field name="res_model">your.object</field>
    <field name="view_type">form</field>
    <field name="view_mode">list,form</field>
</record>

<!-- Action Menu Item Related To Above Action Window -->
<menuitem 
action="action_123" 
id="action_menu_123" 
parent="write_the_parent_menu_id"
name="Readable Text" 
sequence="1"/>
</data>
</openerp>

You may also want to take a look at idea module under your addons directory..%

Avatar
Discard
Author

it did work now i have a menu in the lest with 2 links one to list the list of my records( informations about my patient ) and second one to create a new record ( a new patient) ... Now my problem is i added a third menuitem ( so i can add an apointement for my patients ) but it didnt work .

Author

i created a new file RDV .py , and added in my old Xml file ( the one i used in my module ) another List View Definition and Form View Definition , Action Window Definition and Action Menu Item Related To the new Action Window ... is it the right thing to do or should i create a new XML file ?? and if i shoold create a new one how to relate it to the old one ?

I am not sure if i got what you are asking for, You have one 'action menu item' that opens a list of patients (list view), and a form that shows patient per page (form view).

and you want to have another 'action menu item' to specify an appointment for a patient, am i right?

Author

Yes that's the idea .

ok, ask it in another question instead of extending the current one..%

Author

Ok i did it :), thank you for all your answers

Best Answer

The openERP  structure is __open__.py,__init__.py and module_name.xml.

__open__.py file contains the subsequent file data we have

__init__.py file contains the subsequent py files imports

module_name.xml having all menu items, so you should open this file and add your menu item which ever place you want

        <menuitem name="Employee" id="employee_menu_root"  />
        <menuitem name="Employee profile" id="employee_profile" parent="employee_menu_root" />
        <menuitem name="profile" id="candidate_profile" parent="employee_profile"" />

Avatar
Discard
Best Answer

Hi sey

Look below example :

<menuitem name="Example" action="define_your_menu_action" id="define_your_id" parent="parent_menu_id"/>

In menuitem name tag give your menu name and in action tag define your view action and in id tag define menu_id and parent tag give parent menu id means give id in which model menu you want to display your new menu.

Thank You

Avatar
Discard
Author

thank you very muuuch :)

Related Posts Replies Views Activity
1
Mar 15
3858
3
Jan 24
14388
17
Apr 23
68357
0
Dec 24
556
4
Jan 23
12816