I'm wondering if there is a good way to display inherited data from the third parent. To clarify the question let's take an example.
Assume that we have 4 table:
- Departments
- Teams
- Teams_employees
- Employees
Each department have many teams (many2one
relation) and each team contain many employees (many2many
) with some other useful details in the relation table teams_employees
.
In the department view I want to display all its employees with all the details needed from teams_employees and employees. I'm wondering if there is a simple ORM method or a short XML code as :
<field name="name" string="Department Name">
<tree>
<field name="team_ids">
<field name="name" string="Name Team">
<field name="teams_employees_ids">
<field name="employees_id">
<field name="name" string="Name Employee"/>
</field>
<field name="position" string="Position in this team"/>
</field>
</field>
</tree>
Or if there is a simple method with related field to relate the department through its teams to all the employees.
I'm stuck here for two day and didn't find a solution like what I'm used to do in CakePhp for example :
foreach($this->departement->teams as $team){
//display data
foreach($team->employees as $employee){
//display data
}
}
I tried to add the id department to Teams_employees
but it seems a little bit weird.
Is there a better solution to solve it ?
Any help will be appreciated. Thanks a lot.