[IMP] flow of workflow.workitem.process
bzr revid: xmo@openerp.com-20130319154857-q7l99vyqtksegiy0
This commit is contained in:
parent
2d251ea987
commit
5f956523d4
|
@ -40,30 +40,26 @@ def create(cr, act_datas, inst_id, ident, stack):
|
||||||
process(cr, res, ident, stack=stack)
|
process(cr, res, ident, stack=stack)
|
||||||
|
|
||||||
def process(cr, workitem, ident, signal=None, force_running=False, stack=None):
|
def process(cr, workitem, ident, signal=None, force_running=False, stack=None):
|
||||||
if stack is None:
|
assert stack is not None
|
||||||
raise 'Error !!!'
|
|
||||||
result = True
|
|
||||||
cr.execute('select * from wkf_activity where id=%s', (workitem['act_id'],))
|
cr.execute('select * from wkf_activity where id=%s', (workitem['act_id'],))
|
||||||
activity = cr.dictfetchone()
|
activity = cr.dictfetchone()
|
||||||
|
|
||||||
|
if workitem['state'] == 'running':
|
||||||
|
return True
|
||||||
|
|
||||||
triggers = False
|
triggers = False
|
||||||
if workitem['state']=='active':
|
if workitem['state'] == 'active':
|
||||||
triggers = True
|
triggers = True
|
||||||
result = _execute(cr, workitem, activity, ident, stack)
|
if not _execute(cr, workitem, activity, ident, stack):
|
||||||
if not result:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if workitem['state']=='running':
|
if force_running or workitem['state'] == 'complete':
|
||||||
pass
|
|
||||||
|
|
||||||
if workitem['state']=='complete' or force_running:
|
|
||||||
ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack)
|
ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack)
|
||||||
triggers = triggers and not ok
|
triggers = triggers and not ok
|
||||||
|
|
||||||
if triggers:
|
if triggers:
|
||||||
cr.execute('select * from wkf_transition where act_from=%s', (workitem['act_id'],))
|
cr.execute('select * from wkf_transition where act_from=%s', (workitem['act_id'],))
|
||||||
alltrans = cr.dictfetchall()
|
for trans in cr.dictfetchall():
|
||||||
for trans in alltrans:
|
|
||||||
if trans['trigger_model']:
|
if trans['trigger_model']:
|
||||||
ids = wkf_expr._eval_expr(cr,ident,workitem,trans['trigger_expr_id'])
|
ids = wkf_expr._eval_expr(cr,ident,workitem,trans['trigger_expr_id'])
|
||||||
for res_id in ids:
|
for res_id in ids:
|
||||||
|
@ -71,7 +67,7 @@ def process(cr, workitem, ident, signal=None, force_running=False, stack=None):
|
||||||
id =cr.fetchone()[0]
|
id =cr.fetchone()[0]
|
||||||
cr.execute('insert into wkf_triggers (model,res_id,instance_id,workitem_id,id) values (%s,%s,%s,%s,%s)', (trans['trigger_model'],res_id,workitem['inst_id'], workitem['id'], id))
|
cr.execute('insert into wkf_triggers (model,res_id,instance_id,workitem_id,id) values (%s,%s,%s,%s,%s)', (trans['trigger_model'],res_id,workitem['inst_id'], workitem['id'], id))
|
||||||
|
|
||||||
return result
|
return True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------- PRIVATE FUNCS --------------------------------
|
# ---------------------- PRIVATE FUNCS --------------------------------
|
||||||
|
@ -146,8 +142,6 @@ def _execute(cr, workitem, activity, ident, stack):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _split_test(cr, workitem, split_mode, ident, signal=None, stack=None):
|
def _split_test(cr, workitem, split_mode, ident, signal=None, stack=None):
|
||||||
if stack is None:
|
|
||||||
raise 'Error !!!'
|
|
||||||
cr.execute('select * from wkf_transition where act_from=%s', (workitem['act_id'],))
|
cr.execute('select * from wkf_transition where act_from=%s', (workitem['act_id'],))
|
||||||
test = False
|
test = False
|
||||||
transitions = []
|
transitions = []
|
||||||
|
|
Loading…
Reference in New Issue