Odoo Help


2 Answers


#-*- 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"/>

Gaston Huot Canada
3/24/15, 9:37 AM

Did you find the answer to your question ?

I also want to do that (by the way this forum is not that good for resolving issues? There is no answer to your question. The LinkedIn group seems, at first, better for that)



Ask a Question
Keep Informed
3 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