Odoo Help

4

3
2 Answers
0

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>

0
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)

Thanks,

GH

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.

Register
Odoo Training Center

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

Test it now