Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
3021 Переглядів

Hello, Recently I noticed that there is a _parent_store attribute in a product.category, I checked in odoo, but didn't get the exact idea why it is used. Can anybody help me to understand what the _parent_store attribute actually does? Thank you in advance :)

Аватар
Відмінити
Найкраща відповідь

Parent-child tree relationships are represented using a many-to-one relationship with the same model, where each record holds a reference to its parent. The inverse one-to-many relationship represents the record's direct children.

product.category model uses hierarchical data structures (parent-child relationships), Optimize hierarchy tree searching can be enabled by setting the _parent_store=True model attribute and adding the parent_path helper field. This helper field stores additional information about the hierarchy tree structure, which is used to run faster queries

Note: the parent_path field must also be added, and it must be indexed.

Аватар
Відмінити
Автор

Thank you Waleed Ali Mohsen, Now I am getting what the _parent_store is! This explanation saves a lot of my time.

Найкраща відповідь

Hi Jay,

It is a Nested set of model.It manage hierarchical data structures with unbound depth in SQL. The article Managing Hierarchical Data in MySQL .

_parent_store to False should be sufficient as a workaround for an existing database. The framework can handle child_of operator on models where _parent_store is False, it will simply do multiple queries for traversing the hierarchy. Only the parent_id column is required for child_of.

Regards

Аватар
Відмінити
Автор

So basically, It just simply used to optimize the backend performance by reducing no. of queries

Related Posts Відповіді Переглядів Дія
0
лип. 25
1570
2
лист. 24
6701
2
жовт. 24
3601
2
серп. 24
2058
3
лип. 24
8453