Skip to Content
Menu
This question has been flagged
1 Reply
4028 Views

in odoo 10 its possible to create treeview inside treeview using view_type: 


 tree


for examble: 


                    Chart of Accounts            account.account                        tree                        [('parent_id','=',False)]            {'view_all': True}        



 and its will make parent child accounts view, something like this:


00000000

​1111111111

​222222222

​33333333333


but this feature is dropped in odoo-13, is there are an alternative way to make similar view?

Avatar
Discard
Best Answer

Hi,

In Odoo 10, you can create a tree view inside another tree view by defining related fields and using the groups feature in the XML view definition. This allows you to display related records as a nested tree view within the parent tree view.

Here's a step-by-step guide on how to achieve this:

  1. Define Related Fields: First, you need to define related fields in your model. These related fields will establish the relationship between the parent and child records.For example, let's assume you have two models: parent.model and child.model. You want to display a list of related child.model records within the parent.model tree view. You would define a related field in the parent.model like this:

    from odoo import models, fields

    class ParentModel(models.Model):
        _name = 'parent.model'
        _description = 'Parent Model'

        name = fields.Char(string='Name')
        child_ids = fields.One2many('child.model', 'parent_id', string='Children')

    Define the Parent Tree View: In your XML view definition for the parent.model, define a tree view for it. Include the related field child_ids to display the related records.

<record id="view_parent_model_tree" model="ir.ui.view">
<field name="name">parent.model.tree</field>
<field name="model">parent.model</field>
    <field name="arch" type="xml">
        <tree>
<field name="name"/>
            <field name="child_ids" widget="one2many_list">
                <form string="Child Records">
                    <field name="field1"/>
                    <field name="field2"/>
<!-- Add more fields as needed -->
                </form>
            </field>
        </tree>
    </field>
</record>

  1. The widget="one2many_list" attribute tells Odoo to display the related records as a nested list view within the parent tree view.
  2. Define the Child Tree View (Optional): If you want to customize the tree view for the child.model, you can define a separate tree view for it in a similar way.
  3. Apply Security Groups (Optional): If you want to restrict access to certain records, you can use Odoo's security groups to control who can see the child records within the parent tree view.

Once you've defined the related fields and created the appropriate views, you should be able to see the child records displayed as a nested tree view within the parent tree view.

Keep in mind that this approach allows you to display related records in a nested fashion within the parent tree view. If you need more complex tree view structures, you might need to explore custom Odoo module development or consult with an Odoo developer for additional customization.


Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
0
Jun 15
3723
0
Mar 15
3933
0
Aug 15
8130
1
Oct 23
2559
3
Mar 24
26446