Community mailing list archives

community@mail.odoo.com

Re: categories: what are parent_left and parent_rigth

by
Ferdinand Gassauer
- 09/11/2015 05:01:01
Hi
Best is to alter the table, droping left and right and update the module
open erp will recreate the fields and compute the values

On 2015-09-11 10:57, Jean-Sébastien Suzanne wrote:
<blockquote cite="mid:CAJg4io3qRpeXQYiY9kd-Ux0aUvmLOpQKcmv47L4kwAqzUj=UPA@mail.gmail.com" type="cite">


2015-09-11 10:42 GMT+02:00 robert <robert@redcor.ch>:
Thanks Jay,

On 11.09.2015 09:26, Jay Vora wrote:
<blockquote cite="mid:CACHFH7nhPT2G4QWbkdKSh=wfQFQErpHR28KH4eFSa52CyQObzA@mail.gmail.com" type="cite">
Robert,

Please check here.
very interesting,

now I wonder, how are parent_left and parent_rigth set, when a new category record is created.
I see, that whenever I create a new category, the values of the existing ones are adapted.
By Sql query
1) determine the position of the new position of the category to find the parent left (exemple parent_left = n)
2) update all the category where the parent_left is greater:
     update product_category set parent_left = parent_left + 2, parent_right=parent_right + 2 where parent_left >= n;
     // + 2 because 1 for the parent left + 1 for the parent_right of the new category
3) apply the parent left/right at the new category
     update product_category set parent_left=n parent_right=n+1 where id = "id of the new category"

This method can be slow to update but it is efficient to:
* find children: select * from product_category where parent_left > myparentleft and parent_right < myparentright
* find parents: select * from product_category where parent_left < myparentleftorright and parent_right > myparentleftorright


However greping the source, I did not find the piece of code, where the calculation of the new values is done.
<blockquote cite="mid:CACHFH7nhPT2G4QWbkdKSh=wfQFQErpHR28KH4eFSa52CyQObzA@mail.gmail.com" type="cite">

Thanks.

On Fri, Sep 11, 2015 at 12:44 PM, robert rottermann <robert@redcor.ch> wrote:
Hi there,

in my quest to mass import partners I need to generate categories.
This I can to using an sql statement like the following:
statement = "INSERT INTO res_partner_category (id, name, active, parent_id) 
VALUES (DEFAULT, '%s', 't', %s) RETURNING id" % (name, pid)

however, when I look at the database structure of res_partner_category, i find 
that there are the two fields: parent_left and parent_rigth
What are they for?
And more importantly: what values should they have?

thanks
robert

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
The Splendid journey of 2 years in Numbers
---
Regards,
Jay Vora,
Managing Director,
<img src="cid:part1.09000700.05080805@serpentcs.com" style="color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Serpent Consulting Services Pvt. Ltd.
Web : http://www.serpentcs.com
Mobile : 91 - 9879354457
Twitter: jaynvora
Skype: jaynvora
Blog : http://jayvora.blogspot.com

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Jean-Sébastien SUZANNE
jssuzanne@anybox.fr

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe