2
votes

I am new to OpenERP and I wish to know about that what is model="ir.ui.menu" in OpenERP. Like this there are many other models also there.

For eg:

model="ir.ui.view"

model="ir.actions.act_window"

Can any one explain all this?

4

4 Answers

3
votes

With the ir.ui.menu model you can create new menu items. You can use the menuitem tag, it is shortcut:

<record id="menu_human_readable_name" model="ir.ui.menu" >
    <field name="name">Human readable name</field>
    <field name="sequence" eval="10" />
    <field name="action" ref="action_name" />
    <field name="parent_id" ref="base.menu_custom" />
</record>

And you have a small explanation of the ir.actions.act_window model in the Odoo documentation. You can assign the id of this kind of action in the field action of the ir.ui.menu model

The most common action type, used to present visualisations of a model through views: a window action defines a set of view types (and possibly specific views) for a model (and possibly specific record of the model).

<record id="action_human_readable_name_act_window" model="ir.actions.act_window">
    <field name="type">ir.actions.act_window</field>
    <field name="name">Human readable name</field>
    <field name="res_model">model.name</field>
    <field name="view_mode">tree,form</field>
    <field name="view_type">form</field>
    <field name="target">current</field>
    <field name="domain">[]</field>
    <field name="context">{}</field>
    <field name="search_view_id" ref="ir.ui.view" />
</record>

The ir.ui.view is used for the views where you show the field or tree list

You have more information in the Odoo Documentation:

Views define the way the records of a model are displayed. Each type of view represents a mode of visualization (a list of records, a graph of their aggregation, …). Views can either be requested generically via their type (e.g. a list of partners) or specifically via their id. For generic requests, the view with the correct type and the lowest priority will be used (so the lowest-priority view of each type is the default view for that type).

<record model="ir.ui.view" id="view_id">
    <field name="name">view.name</field>
    <field name="model">object_name</field>
    <field name="priority" eval="16"/>
    <field name="arch" type="xml">
        <!-- view content: <form>, <tree>, <graph>, ... -->
        [...]
        <field name="field_name" />
        [...]
    </field>
</record>
2
votes

Menus and Actions

Menus are records in the ir.ui.menu table. In order to create a new menu entry, you can directly create a record using the record tag.

<record id="menu_external_id" model="ir.ui.menu">
  <field name="name">New Menu</field>
  <field name="action" ref="action_external_id"/>
  <field name="sequence" eval="<integer value>" />
  <field name="parent_id" ref="parent_menu_external_id"/>
</record>

There is a shortcut by using the menuitem tag that you should use preferentially. It offers a flexible way to easily define the menu entry along with icons and other fields.

<menuitem id="menu_external_id"
    name="New Menu"
    action="action_external_id"
    icon="ICON_NAME"
    groups="groupname"
    sequence="<integer value>"
    parent="parent_menu_external_id"
/>

If you remove parent/parent_id from menu/menuitem then it becames top level menu.

Actions

action specifies the identifier of the attached action defined in the action table (ir.actions.act_window). This field is not mandatory : you can define menu elements without associating actions to them. This is useful when defining custom icons for menu elements that will act as folders. This is how custom icons for “Projects” or “Human Resources” in OpenERP are defined).

The actions define the behavior of the system in response to the actions of the users ; login of a new user, double-click on an invoice, click on the action button, ...

There are different types of simple actions:

  • Window: Opening of a new window
  • Report: The printing of a report

     - Custom Report: The personalized reports  
     - RML Report: The XSL:RML reports
    
  • Execute: The execution of a method on the server side
  • Group: Gather some actions in one group

The actions are used for the following events:

  • User connection.
  • The user clicks on a menu.
  • The user clicks on the icon ‘print’ or ‘action’.

    <record id="action_external_id" model="ir.actions.act_window">
        <field name="name">action.name</field>
        <field name="view_id" ref="view_external_id" />
        <field name="domain">[('field','operator','value')]</field>
        <field name="context">{'key':value}</field>
        <field name="res_model">Model Name</field>
        <field name="view_type">form|tree</field>
        <field name="view_mode">form,tree|tree,form|form|tree</field>
        <field name="target">new/current</field> 
    </record>
    
2
votes

I hope you will easily understand my explanation below:

"ir.ui.menu" is a model which is mapped as ir_ui_menu table of database that stores data of menus in Odoo (OpenERP). Every menu in Odoo (OpenERP) is inserted via xml file and stored in database. Also, "ir.ui.view" stores view data (such as form, tree, and search views) and "ir.actions.act_window" stores action data.

Conclusion: Mostly (not all), models inside OpenERP are manifestation of tables inside database.