Skip to Content
Menu
This question has been flagged
10 Replies
32670 Views

Hello,

Any body know how to create a second tree for the same model with different fields in the view ?

Thanks.

Avatar
Discard

Why not create a single view and simply give viewing access to different groups. So some groups will see some columns while another group will see a different set of columns in the same tree. Thus you will kind of accomplish what you want.

Author

Hello thank you kaynis , but i dont want to use groups of user because i already work with multi society and multi users .. thx :)

Best Answer


Hi,

ir.actions.act_window has view_ids attribute to specify views. You can  create multiple tree views and assign to different actions.

Note : Not sure workable in older versions !!


Thanks !


iWesabe

Avatar
Discard
Best Answer
<record id="planned_task_line_tree" model="ir.ui.view">
        <field name="name">planned.task.line.tree</field>
        <field name="model">planned.task.line</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Planned Task Line">
                <field name="name"/>
                <field name="product_id" on_change="onchange(product_id)"/>
                <field name="uom_id"/>
                <field name="planned_qty"/>
                <field name="project_weight" />
                <field name="actual_weight" />
                <field name="completion" on_change="onchange_validation(completion)" invisible="1"/>
                <field name="prev_task_completion" invisible="1" />
                <field name="diff_task_completion" invisible="1" />
            </tree>
        </field>
    </record>




    <record model="ir.actions.act_window" id="act_open_planned_task_line">
       <field name="name">Planned Task Line</field>
       <field name="res_model">planned.task.line</field>
       <field name="view_type">form</field> 
       <field name="view_id" ref="planned_task_line_tree"/>
       <field name="context">{ 'tree_view_ref':'planned_task_line_tree'}</field>    
       <field name="view_mode">tree,form</field> 
    </record> 

    <menuitem action="act_open_planned_task_line" id="planned_task_line" name="Planned Task Line" parent="base.plannedtask" sequence="2"/>



  <record id="planned_task_line_tree2" model="ir.ui.view">
        <field name="name">planned.task.line.tree2</field>
        <field name="model">planned.task.line</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Planned Task Line">
                <field name="g_project_id"/>
                <field name="g_task_id"/>
                <field name="group_activity_id"/>
                 <field name="activities_id" />
                <field name="product_id" />

            </tree>
        </field>
    </record>

<record model="ir.actions.act_window" id="act_open_planned_task_line2">
       <field name="name">Planned Task Line Group</field>
       <field name="res_model">planned.task.line</field>
       <field name="view_type">form</field>  
       <field name="view_mode">tree,form</field>    
       <field name="view_id" ref="planned_task_line_tree2"/>
       <field name="context">{ 'tree_view_ref':'planned_task_line_tree2'}</field>
       </record> 

    <menuitem action="act_open_planned_task_line2" id="planned_task_line2" name="BOQ Acitivity Groups" parent="base.plannedtask" sequence="4"/>

here is my example of 2 tree views for the same clas.. hope it will help :D

Avatar
Discard
Author

Hi thanks for the answer but it dosnt work for me. I added the context field in the view with the view_id .. but it still not working :(

Hi Laribi. Do you got answer for this?

Best Answer

Create a Split action for your object like this create a tree view and action for that tree view and write split view for tree as mentioned below

<record id="tree_id" model="ir.actions.act_window.view"> <field eval="3" name="sequence"/> <field name="view_mode">tree</field> <field name="view_id" ref="tree_view_id"/> <field name="act_window_id" ref="action_id"/> </record>

and if you want another tree view create new tree view and action for that tree view and create split action for newly created action like this

<record id="tree_id1" model="ir.actions.act_window.view"> <field eval="3" name="sequence"/> <field name="view_mode">tree</field> <field name="view_id" ref="tree_view_id1"/> <field name="act_window_id" ref="action_id1"/> </record>

Avatar
Discard
Author

Thanks Maniganda , it works for normal model . But in the case of inherited model it dosent . Any idea ?

Author

It worked thank you Maniganda

Best Answer

Problem Statement

First of all you may know the problem that what's the problem that we are facing here. For example we have a model "model.A" and we have also a tree and form view associated with that model (model.A). And we have one menu named "menuA", and this menu is visible to the only one group of users such as "Staff". When any user related to staff group will click on "menuA" than our above created form and tree view will be displayed to the cited user. And for that group of users we need that all the fields should be editable mode. That's working fine. Now the problem is what we have do when we have different group of users, and for that users we need to show some fields in readonly mode.

Solution

To do that we have different solutions but here we are going to resolve this issue by splitting action window. First we will create a new form and tree view which we want to show different group of users, than we will create an action window using "ir.actions.act_window" model. If you want to read more about action window read this article Action Window in Odoo.

 <record model="ir.actions.act_window" id="parent_action_window">
    <field name="name">Parent Action Window</field>
    <field name="res_model">model.A</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
</record>
 <record id="child_action_window_tree" model="ir.actions.act_window.view">
<field name="view_mode">tree</field>
<field name="view_id" ref="newly_created_tree_view_id_goes_here" />
<field name="act_window_id" ref="parent_action_window" />
</record>
 <record id="child_action_window_form" model="ir.actions.act_window.view">
<field name="view_mode">form</field>
<field name="view_id" ref="newly_created_form_view_id_goes_here" />
<field name="act_window_id" ref="parent_action_window" />
</record>

To get more details read : http://learnopenerp.blogspot.com/2017/12/display-multiple-form-and-tree-view-for.html

Avatar
Discard