Monday, 26 December 2016

How Create Inherited Tree view

How Create Inherited Tree view

1) Create parent field and child field as below

class object_object(models.Model):
    _name = 'object.object'

    name = fields.Char('Name')
    parent_id = fields.Many2one('object.object','Parent Field')
    child_id = fields.One2many('object.object', 'parent_id', string='Child Field')

2) Create simple tree view and add field as 'field_parent' as below

<record id="inherited_tree_view_example" model="ir.ui.view">
            <field name="name">object.object.tree</field>
            <field name="model">object.object</field>
            <field name="field_parent">child_id</field>
            <field name="arch" type="xml">
                <tree string="String Name">
                    <field name="name"/>
                </tree>
                or
                <tree toolbar="True" string="String Name">
                    <field name="name"/>
                </tree>
            </field>
        </record>

3) Create simple action as below

        <record id="inherited_tree_view_action" model="ir.actions.act_window">
            <field name="name">Action Name</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">object.object</field>
            <field name="domain">[('parent_id','=',False)]</field>
            <field name="view_type">tree</field>
            <field name="view_id" ref="inherited_tree_view_example"/>
        </record>
4) Create simple menu as below

        <menuitem action="inherited_tree_view_action" id="menu_id"/>

No comments:

Post a Comment

Odoo 17 New Features

  Odoo 17 new Features 1) Duplicate  multiple records from List view. Please have look below screenshots first you need to select records th...