Merge lp:~openerp-chinese-team/openobject-addons/fix-inefficient-mrp-scheduler into lp:openobject-addons/6.0

Proposed by digitalsatori(Shine IT) on 2012-03-25
Status: Merged
Approved by: Xavier ALT on 2012-03-29
Approved revision: no longer in the source branch.
Merged at revision: 5169
Proposed branch: lp:~openerp-chinese-team/openobject-addons/fix-inefficient-mrp-scheduler
Merge into: lp:openobject-addons/6.0
Diff against target: 20 lines (+5/-4)
1 file modified
procurement/schedulers.py (+5/-4)
To merge this branch: bzr merge lp:~openerp-chinese-team/openobject-addons/fix-inefficient-mrp-scheduler
Reviewer Review Type Date Requested Status
Core devs 2012-03-25 Pending
Review via email: mp+99208@code.launchpad.net

Description of the Change

When there exists thousands of procurements, sorting by planed_date is extremely time consuming, and it is not necessary. removed sorting, added a domain filter, commit for every 500 procurments processed

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'procurement/schedulers.py'
2--- procurement/schedulers.py 2011-01-14 00:11:01 +0000
3+++ procurement/schedulers.py 2012-03-25 14:30:26 +0000
4@@ -53,11 +53,12 @@
5
6 procurement_obj = self.pool.get('procurement.order')
7 if not ids:
8- ids = procurement_obj.search(cr, uid, [], order="date_planned")
9- for id in ids:
10+ ids = procurement_obj.search(cr, uid, [('state', '=', 'exception')])
11+ qty_procs = len(ids)
12+ for i, id in enumerate(ids, 1):
13 wf_service.trg_validate(uid, 'procurement.order', id, 'button_restart', cr)
14- if use_new_cursor:
15- cr.commit()
16+ if ((i%500 == 0) or (qty_procs == i)) and use_new_cursor:
17+ cr.commit()
18 company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
19 maxdate = (datetime.today() + relativedelta(days=company.schedule_range)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
20 start_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss')