Activity log for bug #899470

Date Who What changed Old value New value Message
2011-12-03 01:17:51 Sébastien BEAU - http://www.akretion.com bug added bug
2011-12-05 08:15:27 Priyesh (OpenERP) tags maintenance
2011-12-05 08:15:35 Priyesh (OpenERP) openobject-addons: assignee OpenERP Publisher's Warranty Team (openerp-opw)
2011-12-07 18:09:51 Sébastien BEAU - http://www.akretion.com description Hi all Everything is in the title ;) When I open the menu location form warehouse=>configuration=>warehouse management=>location OpenERP need 45 second (on a core i5) to open the menu, python process run at 100% :( The problem is really easy to understand. Let's explain. First mistake: The view "view_location_tree2" in stock_view add the field stock_real and stock_virtual <record id="view_location_tree2" model="ir.ui.view"> <field name="name">stock.location.tree</field> <field name="model">stock.location</field> <field name="type">tree</field> <field name="priority" eval="2"/> <field name="arch" type="xml"> <tree string="Stock Location" colors="blue:usage=='view';darkred:usage=='internal'"> <field name="complete_name"/> <field name="usage"/> <field name="stock_real" invisible="'product_id' not in context"/> <field name="stock_virtual" invisible="'product_id' not in context"/> </tree> </field> </record> In this case we don't need it and so we make it invisible. But making invisible the field will not remove it from the view and we still need to compute them. In this case computing the stock level of the location is useless and long (45s for 4000 product) Second mistake: Using browse method on the object product in the function 'get_product_available' (file : stock/product.py) should be not use. Why? Because we pretch all field with browse method and when you customer have 4000 products translated this is meant that in order to compute the stock level you are going to read the translation of the sale description of all of your product (yes you read it) I just apply an ugly path to test it + uom_ids=[] product2uom = {} - for product in self.browse(cr, uid, ids, context=context): - product2uom[product.id] = product.uom_id.id - uoms_o[product.uom_id.id] = product.uom_id + for product in self.read(cr, uid, ids, ['uom_id'], context=context): + product2uom[product['id']] = product['uom_id'][0] + if not product['uom_id'][0] in uom_ids : uom_ids.append(product['uom_id'][0]) + print 'uom_ids', uom_ids + for uom in self.pool.get('product.uom').browse(cr, uid, uom_ids, context=context): + uoms_o[uom.id] = uom + Just replacing the browse method by a read method and then I was able to open my menu in less than 2 seconds. This is meant that computing stock level can be done 22x faster when you have translated contain!! (great news, no?) Exactly the problem is not the browse method because it's cleaner to use browse in the code ;). The huge problem is that browse method do not support field restriction, I mean we can not just apply a browse on specific field as we can do with the read method. To finish If I remove the two field stock_real and stock_virtual from the tree view opening the menu is instantaneous. Hope my explication is clear. We should really fix this issue. Reading the translation of the sale description for computing the stock is not clean at all ;). Have a nice day everyone Also I send an email to support team with LP link, my customer have an OPW Hi all Everything is in the title ;) When I open the menu "location" from "warehouse=>configuration=>warehouse management=>location" OpenERP need 45 second (on a core i5) to open it, python process run at 100% :( The problem is really easy to understand. Let's explain. Scenario a database with: - 4000 product - two language installed and all product fields translated Two bug : First bug : useless stock level computation is done when we open the menu location Second bug : useless read on all translated field on the object 'product.product' when we compute the stock level First bug: The view "view_location_tree2" in the file "stock/stock_view.xml" add the field "stock_real" and "stock_virtual"         <record id="view_location_tree2" model="ir.ui.view">             <field name="name">stock.location.tree</field>             <field name="model">stock.location</field>             <field name="type">tree</field>             <field name="priority" eval="2"/>             <field name="arch" type="xml">                 <tree string="Stock Location" colors="blue:usage=='view';darkred:usage=='internal'">                     <field name="complete_name"/>                     <field name="usage"/>                     <field name="stock_real" invisible="'product_id' not in context"/>                     <field name="stock_virtual" invisible="'product_id' not in context"/>                 </tree>             </field>         </record> In this case we don't need it and so we make it invisible. But making the field invisible will not remove it from the view and we still need to compute them. In this case computing the stock level of the location is useless and long (45s for 4000 product) Second bug: Using browse method on the object "product.product" in the function 'get_product_available' (file : stock/product.py) should be not use. Why? Because we prefetch all fields with browse method. And when your database have 4000 products translated, the translation of the sale description of all of your product will be read in order to compute the stock level (yes you read it) For this second bug, I just apply an ugly path to test and fix it + uom_ids=[]          product2uom = {} - for product in self.browse(cr, uid, ids, context=context): - product2uom[product.id] = product.uom_id.id - uoms_o[product.uom_id.id] = product.uom_id + for product in self.read(cr, uid, ids, ['uom_id'], context=context): + product2uom[product['id']] = product['uom_id'][0] + if not product['uom_id'][0] in uom_ids : uom_ids.append(product['uom_id'][0]) + print 'uom_ids', uom_ids + for uom in self.pool.get('product.uom').browse(cr, uid, uom_ids, context=context): + uoms_o[uom.id] = uom + Just replacing the browse method by a read method and then I was able to open my menu in less than 2 seconds. It's mean that computing stock level can be done 22x faster when you have translated contain!! (great news, no?) Exactly the problem is not the browse method because it's cleaner to use browse in the code ;). The huge problem is that browse method do not support field restriction, I mean we can not just apply a browse on specific field as we can do with the read method. To finish If I remove the two field stock_real and stock_virtual from the tree view opening the menu is instantaneous. Hope my explication is clear. We should really fix this issue. Reading the translation of the sale description for computing the stock is not clean at all ;). Have a nice day everyone Also I send an email to support team with LP link, my customer have an OPW
2012-01-12 18:37:01 Yann Papouin bug added subscriber Yann Papouin
2012-03-19 16:20:47 Yann Papouin attachment added patch.diff https://bugs.launchpad.net/openobject-addons/+bug/899470/+attachment/2898353/+files/patch.diff
2012-03-19 16:30:21 Yann Papouin attachment removed patch.diff https://bugs.launchpad.net/openobject-addons/+bug/899470/+attachment/2898353/+files/patch.diff
2012-03-19 16:36:26 Yann Papouin attachment added patch_6.0_6.1.diff https://bugs.launchpad.net/openobject-addons/+bug/899470/+attachment/2898408/+files/patch_6.0_6.1.diff
2012-03-20 04:01:06 jonathan G bug added subscriber jonathan G
2012-09-12 06:22:01 Naresh(OpenERP) nominated for series openobject-addons/6.0
2012-09-12 06:22:01 Naresh(OpenERP) bug task added openobject-addons/6.0
2012-09-12 06:22:01 Naresh(OpenERP) nominated for series openobject-addons/6.1
2012-09-12 06:22:01 Naresh(OpenERP) bug task added openobject-addons/6.1
2012-09-12 06:22:12 Naresh(OpenERP) openobject-addons: importance Undecided Low
2012-09-12 06:22:15 Naresh(OpenERP) openobject-addons/6.0: importance Undecided Low
2012-09-12 06:22:18 Naresh(OpenERP) openobject-addons/6.1: importance Undecided Low
2012-09-12 06:22:26 Naresh(OpenERP) openobject-addons/6.0: assignee OpenERP Publisher's Warranty Team (openerp-opw)
2012-09-12 06:22:32 Naresh(OpenERP) openobject-addons/6.1: assignee OpenERP Publisher's Warranty Team (openerp-opw)
2012-09-12 06:23:54 Amit Dodiya (OpenERP) openobject-addons/6.0: status New Fix Released
2012-09-12 06:25:24 Amit Dodiya (OpenERP) openobject-addons/6.1: status New Fix Committed
2012-09-12 06:25:55 Amit Dodiya (OpenERP) branch linked lp:~openerp-dev/openobject-addons/6.1-opw-50947-ado
2014-02-06 15:28:29 Yann Papouin summary [6.0 TRUNK][STOCK] opening menu location take 45 seconds... [6.0][6.1][stock] get_product_available needs optimization
2014-02-06 15:29:52 Yann Papouin bug task added ocb-addons
2014-02-06 15:30:05 Yann Papouin nominated for series ocb-addons/6.1
2014-02-06 15:30:05 Yann Papouin bug task added ocb-addons/6.1
2014-02-06 15:31:36 Yann Papouin ocb-addons/6.1: assignee Yann Papouin (yann-papouin)
2014-02-06 15:31:40 Yann Papouin ocb-addons/6.1: importance Undecided Medium
2014-02-06 15:32:18 Yann Papouin ocb-addons/6.1: status New Fix Committed
2014-02-06 15:52:02 Launchpad Janitor branch linked lp:~yann-papouin/ocb-addons/6.1-bug-899470-stock-product-available-optimization