I know how to make a header->detail
relationship using the One2many
relationship. It is pretty simple, but in the real world we need to have more complicated things than that.
In my case I have these tables.
Student Homework Paper Test
--------------------------------------------
id id id id
name subject title score
The Student
table has
one2many
toHomework
one2many
toPaper
one2many
toTest
and also
Homework
hasmany2one
toStudent
Paper
hasmany2one
toStudent
Test
hasmany2one
toStudent
Resulting in these relationships
Student Homework Paper Test
--------------------------------------------
id id id id
name subject title score
homework_ids student_id student_id student_id
paper_ids
test_ids
I could make a form with Student
model and input Homework
, Paper
, and Test
from that form using the One2many
widget.
But what if I wanted to have a form with Homework
model where I choose a Student
first and then input her Homework
, but also from that form I'd like to see(or input) her other information such as Paper
, and Test
?
Using Many2many
relation between Homework
, Paper
, and Test
just to have the student's Paper
, and Test
accessible from Homework
seems very weird to me. It also complicates the database structure, creating unnecessary Many2many
relation.
Is there another way instead of using Many2many
relation? I feel the database structure will be very ugly if I used that.
This is a huge concern to me as looking at Odoo as it is a heavily model dependent framework. You must start with the right model first!