Odoo Help


1 Answer


#-*- 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')


<?xml version="1.0" encoding="UTF-8"?>
        <!-- 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">
                        <field name="parent_id"/>
                        <field name="code"/>
                        <field name="name"/>
                        <field name="child_ids"/>
    <!-- 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"/>
    <!-- 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>
    <!-- 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"/>


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

Odoo Training Center

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

Test it now