Odoo Help

2

1
1 Answer
5

hierarchy.py

#-*- coding: utf-8 -*-
from openerp import models, fields, api
class hierarchy(models.Model):
    _name = 'hierarchy'
    parent_id = fields.Many2one('hierarchy',string='Superior Level')
    code = fields.Char('Code',required=True)
    name = fields.Char('Name')
    child_ids = fields.One2many('hierarchy', 'parent_id',string='Sub Levels')


hierarchy_view.xml

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
        <!-- views -->
        <!-- form view -->
        <record id="view_form_hierarchy" model="ir.ui.view">
            <field name="name">hierarchy Form</field>
            <field name="model">hierarchy</field>
            <field name="arch" type="xml">
                <form>
                    <group>
                        <field name="parent_id"/>
                        <field name="code"/>
                        <field name="name"/>
                        <field name="child_ids"/>
                    </group>
                </form>
            </field>
    </record>
    <!-- tree ( tree ) view -->
    <record id="view_tree_hierarchy" model="ir.ui.view">
        <field name="name">hierarchy Tree</field>
        <field name="model">hierarchy</field>
        <field name="field_parent">child_ids</field>
        <field name="arch" type="xml">
            <tree toolbar="1">
                <field icon="icon" name="code"/>
                <field name="name"/>
            </tree>
        </field>
    </record>
    <!-- Actions -->
    <record model="ir.actions.act_window" id="action_hierarchy">
        <field name="name">hierarchy</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">hierarchy</field>
        <field name="view_type">tree</field>
        <field name="domain">[('parent_id','=',False)]</field>
    </record>
    <!-- Menu items -->
    <menuitem id="root_hierarchy" name="hierarchy"/>
    <menuitem id="menu_hierarchy" name="Menu" parent="root_hierarchy"/>
    <menuitem id="hierarchy_opcion" name="hierarchy" parent="menu_hierarchy" sequence="20" action="action_hierarchy"/>
    </data>

</openerp>

1 Comment
kampeons India
2/16/17, 11:22 PM

how to open a model while clicking on it(in odoo 9).

like chart of accounts in odoo 8

Ask a Question
Tags
Keep Informed
1 follower(s)
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