_product_all_get() in stock.location calculates children twice

Bug #527826 reported by Albert Cervera i Areny - http://www.NaN-tic.com
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Undecided
JMA(Open ERP)

Bug Description

_product_all_get() in stock.location calculates location children with:

location_ids = self.search(cr, uid, [('location_id', 'child_of', ids)])

but later calls "_product_get_multi_location()" who later calls product.product's get_product_available(). This function also searches all children for the given locations. This means that get_product_available() works with repeated locations.

For example,

* say location ID 1 has 2 children (with IDs 2 and 3)
* say you call stock.location's _product_all_get() with ID 1

This function will call product.product get_product_available() (found in stock/product.py:36) with context={'location': [1,2,3]}
and get_product_available() will try to find the children of all locations in stock/product.py:72 call (but those were already calculated!):

child_location_ids = self.pool.get('stock.location').search(cr, uid, [('location_id', 'child_of', location_ids)])

The result is that child_location_ids will always be equal to location_ids. This isn't extremely bad in itself, but if the company created lots (thousands) of locations this search will crash due to the large amount of location_ids.

Please, see the attached patch which fixes this issue. Hope explanation was clear enough, let me know if it wasn't.

Related branches

Revision history for this message
Albert Cervera i Areny - http://www.NaN-tic.com (albert-nan) wrote :
Changed in openobject-addons:
assignee: nobody → JMA(Open ERP) (jma-openerp)
milestone: none → 5.0.11
status: New → Confirmed
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Albert,
It has been fixed by revision 2741 <email address hidden>.
Thank you for reporting and the patch as well.
For 6.0, we will plan to refactor the methods product_get and product_all_get() as they can be combined into a single method with just a change of context.

Thanks.

Changed in openobject-addons:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.