Hi,
In Odoo, a one2many field (like 'sons' in your father model) doesn't actually store any data directly in the father record or table. Instead, the relationship is managed through the corresponding many2one field in the child model.
Here's what's happening:
-
The father model has a one2many field pointing to sons: sons = fields.One2many('son.model', 'father_id', string="Sons")
-
The son model has a many2one field pointing back to father: father_id = fields.Many2one('father.model', string="Father")
-
In the database:
- The father table doesn't have a column for sons
- Each son record in the son table has a column called father_id that stores the ID of its parent
When you view a father record and see the list of sons, Odoo dynamically fetches all son records where father_id equals the current father's ID. This is done through a database query, not by accessing a stored array.
So to answer your questions directly:
- No, the father record doesn't store sons' IDs
- There is no array field in the database table
- You can add as many sons as you want because each new son simply gets a new record in the son table with the appropriate father_id value
This design is a standard relational database pattern that allows for efficient storage and querying of one-to-many relationships without size limitations.
Regards,
Jishna
Accurates
Could any one help !