Hierarchical relationships
Parent-child tree relationships are represented using a many-to-one relationship with the same model, used for each record to references its parent. The inverse one-to-many relation corresponds to the record's direct children.
Odoo provides improved support for these hierarchical data structures, with the additional child_of and parent_of operators available in domain expressions. These operators are available as long as the model has a parent_id field (or has a _parent_name valid Model definition).
We can enable faster querying on the hierarchy tree by setting the _parent_store=True Model attribute and adding the parent_path helper field. This fields stores additional information about the hierarchy tree structure ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access