← Back to team overview

openerp-india team mailing list archive

[Bug 963031] [NEW] mrp scheduler running very slow when there exists a lot of procurement orders

 

Public bug reported:

when there are thounds of procurement orders, sorting on planed_date
make the search query extremly slow, and it is not necessary here.

Solution:
file modified:   addons/procurement/schedulers.py
Removed date sorting and also added condition to get only procurement orders in 'exceoption' state. commit for every 500 procurement order processed

-                ids = procurement_obj.search(cr, uid, [], order="date_planned")
-            for id in ids: 
+                ids = procurement_obj.search(cr, uid, [('state', '=', 'exception')]) 
+            qty_procs = len(ids) 
+            for i, id in enumerate(ids): 
                 wf_service.trg_validate(uid, 'procurement.order', id, 'button_restart', cr) 
-            if use_new_cursor: 
-                cr.commit() 
+                if (((i+1)%500 == 0) or (qty_procs == (i+1))) and use_new_cursor: 
+                    cr.commit()

** Affects: openobject-addons
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/963031

Title:
  mrp scheduler running very slow when there exists a lot of procurement
  orders

Status in OpenERP Addons (modules):
  New

Bug description:
  when there are thounds of procurement orders, sorting on planed_date
  make the search query extremly slow, and it is not necessary here.

  Solution:
  file modified:   addons/procurement/schedulers.py
  Removed date sorting and also added condition to get only procurement orders in 'exceoption' state. commit for every 500 procurement order processed

  -                ids = procurement_obj.search(cr, uid, [], order="date_planned")
  -            for id in ids: 
  +                ids = procurement_obj.search(cr, uid, [('state', '=', 'exception')]) 
  +            qty_procs = len(ids) 
  +            for i, id in enumerate(ids): 
                   wf_service.trg_validate(uid, 'procurement.order', id, 'button_restart', cr) 
  -            if use_new_cursor: 
  -                cr.commit() 
  +                if (((i+1)%500 == 0) or (qty_procs == (i+1))) and use_new_cursor: 
  +                    cr.commit()

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/963031/+subscriptions


Follow ups

References