Help

4

Project hierarchic tree view?

Is it possible to display the full hierarchic tree of a project with several subproject levels and subtasks? (Both in 6.1 and 7.0)

I will put an example to show what I need and also what I am getting. Let's say we have this kind of multilevel project:

  • Project_1 (level 1)
    • Project_1_1 (n2)
  • - - Task_1_1_a (n2) (parent)
  • - - - Task_1_1_a_a (n3) (child)
    • Project_1_2 (n2)
  • - - Project_1_2_1 (n3)
  • - - - Task_1_2_1_a (n4)
  • - - - Task_1_2_1_b (n4) (parent)
  • - - - - Task_1_2_1_b_a (n5) (child)
  • - - - Task_1_2_1_c (n4)
  • - - - Task_1_2_1_d (n4)
  • - - Project_1_2_2 (n3)
    • Project_1_3 (n2)
  • Project_2 (n1)

As we can see, I can define a multilevel structure with projects-subprojects and tasks-subtasks, as layered as I want. But I cannot show them in a tree, folding and unfolding levels.

The only thing I was able to get is filtering by 'project', but with an unwanted result. That way I can display in 2 levels: 1-projects and 2-tasks. But that just places all projects in the same display level, whether they are parent or child. The same with tasks. Thus I completely loose a global vision and all gets confused.

This is what I get:

  • Project_1 (level 1)
  • Project_1_1 (n2)
    • Task_1_1_a (n2) (parent)
    • Task_1_1_a_a (n3) (child)
  • Project_1_2 (n2)
  • Project_1_2_1 (n3)
    • Task_1_2_1_a (n4)
    • Task_1_2_1_b (n4) (parent)
    • Task_1_2_1_b_a (n5) (child)
    • Task_1_2_1_c (n4)
    • Task_1_2_1_d (n4)
  • Project_1_2_2 (n3)
  • Project_1_3 (n2)
  • Project_2 (n1)

And surely the same happens in analytic contability too.

So... Is there a way to display the full tree? Any module? Anything?

1 Comment
Avatar
Discard
2 Answers
0
Best Answer

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>

Avatar
Discard
0
Avatar
Gaston Huot
Best Answer

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

Avatar
Discard