Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

What means parent_left and parent_right field in product_category table

By
Dotz
on 4/1/13, 6:27 AM 3,311 views

Can someone explain the usage of parent_left and parent_right in database table product_category ? Primary key is id , for treeview there is field parent_id. If parent_id is Null it is a "Master Catecory". I ask this because I want to first import my product categories and afterwards the products / templates.

Thanks in advance.

Dotz

3

Mohammad Alhashash

--Mohammad Alhashash--
2075
| 5 5 8
Giza, Egypt
--Mohammad Alhashash--

Developer

Mohammad Alhashash
On 4/1/13, 7:34 AM

These are the fields for Nested Set Model. Used to manage hierarchical data structures with unbound depth in SQL. The article Managing Hierarchical Data in MySQL explains this model details with examples in SQL.

OpenERP uses Nested Set Model to manage trees like chart of accounts and warehouse locations. parent_left and parent_right columns are equivalent to right and left columns in the above articles.

You do not need to manage these fields yourself; OpenERP will update them and use them for optimized reading and domain evaluation if you add class attribute _parent_store = True in your model. OpenERP can create the parent_left and parent_right database columns automatically but you should define them with select=True attribute to create an index.

If the self reference field is not parent_id (ex. main_category_id), you must define a class attribute _parent_name = 'main_category_id' to enable this model.

Models using these fields can use child_of, parent_left and parent_right domain operators.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/1/13, 6:27 AM
Seen: 3311 times
Last updated: 3/16/15, 8:10 AM