Merge lp:~openerp-dev/openobject-addons/6.1-two-level-scheduler-mat into lp:openobject-addons/6.1

Proposed by Martin Trigaux (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-two-level-scheduler-mat
Merge into: lp:openobject-addons/6.1
Diff against target: 44 lines (+12/-9)
1 file modified
procurement/schedulers.py (+12/-9)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-two-level-scheduler-mat
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) Pending
Review via email: mp+191619@code.launchpad.net

Description of the change

Add skip_exception argument to the run procurement method to allow running without restarting procurement in exception

To post a comment you must log in.
7262. By Martin Trigaux (OpenERP)

[FIX] scheduler: always do commit in scheduler

7263. By Martin Trigaux (OpenERP)

[FIX] schedluer: better user_new_cursor

Unmerged revisions

7263. By Martin Trigaux (OpenERP)

[FIX] schedluer: better user_new_cursor

7262. By Martin Trigaux (OpenERP)

[FIX] scheduler: always do commit in scheduler

7261. By Martin Trigaux (OpenERP)

[ADD] scheduler: parameter skip_exception when run procurement

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 2012-03-16 13:40:52 +0000
3+++ procurement/schedulers.py 2013-10-17 13:20:19 +0000
4@@ -32,15 +32,17 @@
5 class procurement_order(osv.osv):
6 _inherit = 'procurement.order'
7
8- def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
9+ def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, skip_exception=False, context=None):
10 ''' Runs through scheduler.
11 @param use_new_cursor: False or the dbname
12 '''
13- self._procure_confirm(cr, uid, use_new_cursor=use_new_cursor, context=context)
14+ if use_new_cursor:
15+ use_new_cursor = cr.dbname
16+ self._procure_confirm(cr, uid, use_new_cursor=use_new_cursor, skip_exception=skip_exception, context=context)
17 self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
18 use_new_cursor=use_new_cursor, context=context)
19
20- def _procure_confirm(self, cr, uid, ids=None, use_new_cursor=False, context=None):
21+ def _procure_confirm(self, cr, uid, ids=None, use_new_cursor=False, skip_exception=False, context=None):
22 '''
23 Call the scheduler to check the procurement order
24
25@@ -61,12 +63,13 @@
26 wf_service = netsvc.LocalService("workflow")
27
28 procurement_obj = self.pool.get('procurement.order')
29- if not ids:
30- ids = procurement_obj.search(cr, uid, [('state', '=', 'exception')], order="date_planned")
31- for id in ids:
32- wf_service.trg_validate(uid, 'procurement.order', id, 'button_restart', cr)
33- if use_new_cursor:
34- cr.commit()
35+ if not skip_exception:
36+ if not ids:
37+ ids = procurement_obj.search(cr, uid, [('state', '=', 'exception')], order="date_planned")
38+ for id in ids:
39+ wf_service.trg_validate(uid, 'procurement.order', id, 'button_restart', cr)
40+ if use_new_cursor:
41+ cr.commit()
42 company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
43 maxdate = (datetime.today() + relativedelta(days=company.schedule_range)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
44 start_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss')