Odoo Help

1

Two different tree_views for a same model ??

By
laribi
on 9/24/13, 1:20 PM 6,093 views

Hello,

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

Thanks.

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.

kaynis
on 9/24/13, 2:20 PM

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

laribi
on 9/25/13, 10:22 AM
1

Maniganda

--Maniganda--

1098
| 6 8 7
Bangalore, India
--Maniganda--
Maniganda
On 9/25/13, 10:31 AM

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>

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

laribi
on 9/26/13, 7:07 AM

It worked thank you Maniganda

laribi
on 9/26/13, 9:32 AM
0
Sehrish
On 2/14/18, 1:08 AM

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

0


Hi,

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

<field name="view_ids" eval="[(5, 0, 0),

(0, 0, {'view_mode': 'tree', 'view_id': ref('your_module.your_tree_view_id')}),

]"/>

Note : Not sure workable in older versions !!


Thanks !

Shameem Babu @ iWesabe

0
<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

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 :(

laribi
on 9/25/13, 10:21 AM

Hi Laribi. Do you got answer for this?

samba
on 2/16/15, 7:20 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 9/24/13, 1:20 PM
Seen: 6093 times
Last updated: 2/14/18, 1:08 AM