parent_left,parent_right are not recomputed when parent_order is changed

Bug #1253052 reported by Cedric Le Brouster(OpenFire)
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

The parent_left and parent_right params should be recomputed when _parent_order is changed, like it does when _parent_name is changed.

Example:
Install module account.
Duplicate an existing account.
Change the duplicated account code.
Now in accounts list, you can see the duplicated account is not sorted.

bug noticed in both OpenERP 6.1 and 7.0

fix patch joined (made under OpenERP 6.1)

Related branches

Revision history for this message
Cedric Le Brouster(OpenFire) (cedric-lebrouster) wrote :

Update : Correct patch for _parent_order with several fields.

Revision history for this message
Twinkle Christian(OpenERP) (tch-openerp) wrote :

Hello,

Would you please provide screen cast of your testing ? So, According to that I can evaluate it more.

Waiting for your answer.

Thanks

Changed in openobject-server:
status: New → Incomplete
Revision history for this message
Cedric Le Brouster(OpenFire) (cedric-lebrouster) wrote :

Hello,

Thanks for your answer.
Maybe I got a little too far with use of duplicating in my example, actually the problem results of the modification of the field used for parents sorting.

I join an example.
In the upper part, I have the tree view of account_account with filter on 512* accounts.
Then I decide to change code of 'Liquidités' FROM 512101 to 512103.
When I refresh tree view, I would expect 512103 to be under 512102, but it isn't the case.
If I want 'Liquidités' to get in its right place, I have to give it a fake parent account, and then put the good parent account back for OpenERP to recompute parent_left and parent_right fields.

Revision history for this message
Twinkle Christian(OpenERP) (tch-openerp) wrote :

Hello Cedric,

Thanks for the reply and screen shot..!!

Well, This is not a bug, But If you want to see in specific order then you have to see it via chart of account > all entries, and you will see your accounts in right place.

And Also I have shown you in my above video you can also sort your accounts via code, and you will get it in order.

So, its not a bug. In meanwhile I am marking it as a "Invalid".

Hope you understand.

Regards,

affects: openobject-server → openobject-addons
Changed in openobject-addons:
status: Incomplete → Invalid
Revision history for this message
Cedric Le Brouster(OpenFire) (cedric-lebrouster) wrote :

Hello Twinkle,

Thank you for your answer and the video.
I took some time to think about it and read more of the OpenERP code.

You say _parent_order is not meant to be used for computing parent_left attribute.
I found no documentation about this _parent_order behavior, but when I look in orm.py at _parent_store_compute(), write() and create() methods, they all make an 'order by' when computing it.
So why is that? Isn't it wasted time then?

I personally think we can be expecting well sorting of accounts in tree view. The chart of accounts is not designed for account edition.
I know we can sort accounts by code, but that only works for children of the same parent : keep in mind that _parent_order is not specific to account_account. It is also used in product_category, stock_location and res_partner_category, and possibly in custom modules. account_account is a special case in which sorting by code (almost) preserves inheritance order.
For these reasons I'll keep using the patch I made.

I really think this is a bug, of course not a major one, but still a bug.
At least you could set it as a wishlist.

Regards,

I update the joined patch :
 - add a strip() when reading _parent_order params
 - update create() method, that didn't sort new object when created with no parent (while _parent_store_compute() does)

Revision history for this message
Cedric Le Brouster(OpenFire) (cedric-lebrouster) wrote :

I'm understanding a little better the OpenERP launchpad process, I didn't realise I had to set the bug back in 'New' state by myself to get an answer, so I do it today.
Please refer to my previous comment.
By the way, I see it was moved to openobject-addons project, but I really believe it's an openobject-server bug (as the bug concerns osv/orm.py file). In that case, do I have to change it by myself?

Changed in openobject-addons:
status: Invalid → New
Amit Parik (amit-parik)
affects: openobject-addons → openobject-server
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers