Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenERP specify multiple view references on "view_id"

Tags:

openerp

I extended "hr.employee" class. (Inherited and gave the same name to the new one). I defined two views (tree and form) and a menu:

<record model="ir.ui.view" id="my_employee_tree">
   <field name="name">hr.employee.tree</field>
   <field name="model">hr.employee</field>
   <field name="arch" type="xml">
            ...
   </field>
</record>

 <record id="view_my_hr_employee_form" model="ir.ui.view">
        <field name="name">hr.employee.form</field>
        <field name="model">hr.employee</field>
        <field name="arch" type="xml">
            ...
   </field>
</record>

<record model="ir.actions.act_window" id="action_my_hr_employee_seq">
        <field name="name">Angajati</field>
        <field name="res_model">hr.employee</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="view_my_hr_employee_form"/>
    </record>


    <menuitem id="menu_project_hr_base" parent="menu_project_utcn_project_base_main" name="HR"/>
<menuitem action="action_my_hr_employee_seq" id="menu_action_employee_form" name ="Angajati" parent="menu_project_hr_base"/>

What I want to do is to get the original views from hr.employee view when i use the original module, and to get my defined views when i use my module.

As you can see, I have specified "view_id" reference to my form view, but how can i define a reference also to my tree view? And I want the tree view to be shown first, and form view as alternative. How can i specify this?

<field name="view_mode">tree,form</field> 

seems not to work if i add reference to form view

like image 432
dan zetea Avatar asked Apr 26 '13 21:04

dan zetea


1 Answers

You have to map your action with particular tree,form view.

Try this:

<record model="ir.actions.act_window" id="action_my_hr_employee_seq">
    <field name="name">Angajati</field>
    <field name="res_model">hr.employee</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
</record>

<record model="ir.actions.act_window.view" id="act_hr_employee_tree_view">
    <field eval="1" name="sequence"/>
    <field name="view_mode">tree</field>
    <field name="view_id" ref="your_tree_view_id"/>
    <field name="act_window_id" ref="action_my_hr_employee_seq"/>
</record>

<record model="ir.actions.act_window.view" id="act_hr_employee_form_view">
    <field eval="2" name="sequence"/>
    <field name="view_mode">form</field>
    <field name="view_id" ref="your_form_view_id"/>
    <field name="act_window_id" ref="action_my_hr_employee_seq"/>
</record>
like image 146
Sudhir Arya Avatar answered Nov 05 '22 11:11

Sudhir Arya