This question has been flagged
1 Reply
3917 Views

I have two form views and two tree views for an object, to decide which tree view will open, I used the PRIORITY concept, I did it by action : It means that for an action I specified wich tree view will open when the action is invoked, and this by adding : 

<field name="view_id" ref="view_order_tree"/>, view_order_tree is the id of the tree view I want to diplay for this action.

The problem is, how to do the same thing for the form view, I want to do it by action too, do you have any idea ? 

Avatar
Discard
Author Best Answer

So I'll answer myself, hoping that might help other people.

Having several views of the same type is very recurrent in openerp, so the most complete solution is not the priority, and it's not the "by action" method, it's the DISPLAY MODE solution.

So for example, for an action action_orders, I'll assign for each DISPLAY MODE ( the horizantal list of possible views to display that we have below the search filter ), the view to show, because I have of course many possibilities for each type of view. and that is possible by this code : 

        <record model="ir.actions.act_window.view" id="action_sale_order_tree">

            <field name="sequence" eval="1"/>

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

            <field name="view_id" ref="view_order_tree"/>

            <field name="act_window_id" ref="action_orders"/>

        </record>

 

        <record model="ir.actions.act_window.view" id="action_sale_order_form">

            <field name="sequence" eval="3"/>

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

            <field name="view_id" ref="view_order_form"/>

            <field name="act_window_id" ref="action_orders"/>

        </record>

So I assigned via the view_id field, the id of the view to display when clicking on the display mode, according to what type of view I want to display. all of that is hapenning when action_orders is invoked via menu click.

So I hope that helps someone.

Avatar
Discard