=== modified file 'procurement/schedulers.py' --- procurement/schedulers.py 2011-01-14 00:11:01 +0000 +++ procurement/schedulers.py 2012-01-18 19:01:57 +0000 @@ -53,13 +53,18 @@
procurement_obj = self.pool.get('procurement.order') if not ids: - ids = procurement_obj.search(cr, uid, [], order="date_planned") + ids = procurement_obj.search(cr, uid, + [('state', '=', 'exception')], order="date_planned") for id in ids: - wf_service.trg_validate(uid, 'procurement.order', id, 'button_restart', cr) + wf_service.trg_validate(uid, 'procurement.order', + id, 'button_restart', cr) if use_new_cursor: cr.commit() - company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id - maxdate = (datetime.today() + relativedelta(days=company.schedule_range)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT) + company = self.pool.get('res.users').browse(cr, uid, + uid, context=context).company_id + maxdate = (datetime.today() + \ + relativedelta(days=company.schedule_range)).\ + strftime(tools.DEFAULT_SERVER_DATE_FORMAT) start_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss') offset = 0 report = [] @@ -67,19 +72,25 @@ report_except = 0 report_later = 0 while True: - cr.execute("select id from procurement_order where state='confirmed' and procure_method='make_to_order' order by priority,date_planned limit 500 offset %s", (offset,)) - ids = map(lambda x: x[0], cr.fetchall()) - for proc in procurement_obj.browse(cr, uid, ids, context=context): + ids = procurement_obj.search(cr, uid, [ + ('state', '=', 'confirmed'), + ('procure_method', '=', 'make_to_order') + ], offset=offset, limit=500, + order='priority, date_planned', context=context + ) + for proc in procurement_obj.browse(cr, uid, ids, + context=context): if maxdate >= proc.date_planned: - wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr) + wf_service.trg_validate(uid, + 'procurement.order', proc.id, 'button_check', cr) else: - offset += 1 report_later += 1 - for proc in procurement_obj.browse(cr, uid, ids, context=context): + offset += 1 + if proc.state == 'exception': - report.append('PROC %d: on order - %3.2f %-5s - %s' % \ - (proc.id, proc.product_qty, proc.product_uom.name, - proc.product_id.name)) + report.append(_('PROC %d: on order - %3.2f %-5s - %s') % \ + (proc.id, proc.product_qty, proc.product_uom.name, + proc.product_id.name)) report_except += 1 report_total += 1 if use_new_cursor: @@ -90,20 +101,25 @@ ids = [] while True: report_ids = [] - ids = procurement_obj.search(cr, uid, [('state', '=', 'confirmed'), ('procure_method', '=', 'make_to_stock')], offset=offset) + ids = procurement_obj.search(cr, uid, [ + ('state', '=', 'confirmed'), + ('procure_method', '=', 'make_to_stock') + ], offset=offset) for proc in procurement_obj.browse(cr, uid, ids): if maxdate >= proc.date_planned: - wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr) + wf_service.trg_validate(uid, + 'procurement.order', proc.id, 'button_check', cr) report_ids.append(proc.id) else: report_later += 1 report_total += 1 - for proc in procurement_obj.browse(cr, uid, report_ids, context=context): + if proc.state == 'exception': - report.append('PROC %d: from stock - %3.2f %-5s - %s' % \ - (proc.id, proc.product_qty, proc.product_uom.name, - proc.product_id.name,)) + report.append(_('PROC %d: from stock - %3.2f %-5s - %s') % \ + (proc.id, proc.product_qty, proc.product_uom.name, + proc.product_id.name,)) report_except += 1 + if use_new_cursor: cr.commit() offset += len(ids) @@ -111,22 +127,23 @@ end_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss') if uid: request = self.pool.get('res.request') - summary = '''Here is the procurement scheduling report. - - Start Time: %s - End Time: %s - Total Procurements processed: %d - Procurements with exceptions: %d - Skipped Procurements (scheduled date outside of scheduler range) %d - - Exceptions:\n'''% (start_date, end_date, report_total, report_except, report_later) + summary = _("""Here is the procurement scheduling report. + + Start Time: %s + End Time: %s + Total Procurements processed: %d + Procurements with exceptions: %d + Skipped Procurements (scheduled date outside of scheduler range) %d + + Exceptions:\n""") % (start_date, end_date, report_total, + report_except, report_later) summary += '\n'.join(report) - request.create(cr, uid, - {'name': "Procurement Processing Report.", - 'act_from': uid, - 'act_to': uid, - 'body': summary, - }) + request.create(cr, uid, { + 'name': "Procurement Processing Report.", + 'act_from': uid, + 'act_to': uid, + 'body': summary, + })
if use_new_cursor: cr.commit() @@ -138,6 +155,7 @@ pass return {}
=== modified file 'procurement/ schedulers. py' schedulers. py 2011-01-14 00:11:01 +0000 schedulers. py 2012-01-18 19:01:57 +0000
--- procurement/
+++ procurement/
@@ -53,13 +53,18 @@
if not ids:
- ids = procurement_
+ ids = procurement_
+ [('state', '=', 'exception')], order="
for id in ids:
- wf_service.
+ wf_service.
+ id, 'button_restart', cr)
if use_new_cursor:
- company = self.pool.
- maxdate = (datetime.today() + relativedelta(
+ company = self.pool.
+ uid, context=
+ maxdate = (datetime.today() + \
+ relativedelta(
+ strftime(
offset = 0
report = []
@@ -67,19 +72,25 @@
while True:
- cr.execute("select id from procurement_order where state='confirmed' and procure_
- ids = map(lambda x: x[0], cr.fetchall())
- for proc in procurement_
+ ids = procurement_
+ ('state', '=', 'confirmed'),
+ ('procure_method', '=', 'make_to_order')
+ ], offset=offset, limit=500,
+ order='priority, date_planned', context=context
+ )
+ for proc in procurement_
+ context=context):
- wf_service.
+ wf_service.
+ 'procurement.
- offset += 1
- for proc in procurement_
+ offset += 1
+
- report.append('PROC %d: on order - %3.2f %-5s - %s' % \
- (proc.id, proc.product_qty, proc.product_
- proc.product_
+ report.
+ (proc.id, proc.product_qty, proc.product_
+ proc.product_
if use_new_cursor:
@@ -90,20 +101,25 @@
ids = []
while True:
- ids = procurement_
+ ids = procurement_
+ ('state', '=', 'confirmed'),
+ ('procure_method', '=', 'make_to_stock')
+ ], offset=offset)
- wf_service.
+ wf_service.
+ 'procurement.
- for proc in procurement_
+
- report.append('PROC %d: from stock - %3.2f %-5s - %s' % \
- (proc.id, proc.product_qty, proc.product_
- proc.product_
+ report.
+ (proc.id, proc.product_qty, proc.product_
+ proc.product_
+
if use_new_cursor:
@@ -111,22 +127,23 @@
if uid:
- summary = '''Here is the procurement scheduling report.
-
- Start Time: %s
- End Time: %s
- Total Procurements processed: %d
- Procurements with exceptions: %d
- Skipped Procurements (scheduled date outside of scheduler range) %d
-
- Exceptions:\n'''% (start_date, end_date, report_total, report_except, report_later)
+ summary = _("""Here is the procurement scheduling report.
+
+ Start Time: %s
+ End Time: %s
+ Total Procurements processed: %d
+ Procurements with exceptions: %d
+ Skipped Procurements (scheduled date outside of scheduler range) %d
+
+ Exceptions:\n""") % (start_date, end_date, report_total,
+ report_except, report_later)
- request.create(cr, uid,
- {'name': "Procurement Processing Report.",
- 'act_from': uid,
- 'act_to': uid,
- 'body': summary,
- })
+ request.create(cr, uid, {
+ 'name': "Procurement Processing Report.",
+ 'act_from': uid,
+ 'act_to': uid,
+ 'body': summary,
+ })
if use_new_cursor:
cr.commit( )
pass
@@ -138,6 +155,7 @@
return {}