def process(cr, workitem, ident, signal=None, force_running=False, stack=None): if stack is None: raise 'Error !!!' result = True cr.execute('select * from wkf_activity where id=%s', (workitem['act_id'],)) activity = cr.dictfetchone() triggers = False if workitem['state']=='active': triggers = True result = _execute(cr, workitem, activity, ident, stack) if not result: return False if workitem['state']=='running': pass if workitem['state']=='complete' or force_running: ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack) triggers = triggers and not ok if triggers: cr.execute('select * from wkf_transition where act_from=%s', (workitem['act_id'],)) alltrans = cr.dictfetchall() for trans in alltrans: if trans['trigger_model']: ids = wkf_expr._eval_expr(cr,ident,workitem,trans['trigger_expr_id']) for res_id in ids: cr.execute('select nextval(\'wkf_triggers_id_seq\')') 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)) return result
def process(cr, workitem, ident, signal=None, force_running=False, stack=None): assert stack is not None cr.execute('select * from wkf_activity where id=%s', (workitem['act_id'],)) activity = cr.dictfetchone() triggers = False if workitem['state'] == 'active': triggers = True if not _execute(cr, workitem, activity, ident, stack): return False if force_running or workitem['state'] == 'complete': ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack) triggers = triggers and not ok if triggers: cr.execute('select * from wkf_transition where act_from=%s', (workitem['act_id'],)) for trans in cr.dictfetchall(): if trans['trigger_model']: ids = wkf_expr._eval_expr(cr,ident,workitem,trans['trigger_expr_id']) for res_id in ids: cr.execute('select nextval(\'wkf_triggers_id_seq\')') 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)) return True
def process(cr, workitem, ident, signal=None, force_running=False, stack=None): if stack is None: raise "Error !!!" result = True cr.execute("select * from wkf_activity where id=%s", (workitem["act_id"],)) activity = cr.dictfetchone() triggers = False if workitem["state"] == "active": triggers = True result = _execute(cr, workitem, activity, ident, stack) if not result: return False if workitem["state"] == "running": pass if workitem["state"] == "complete" or force_running: ok = _split_test(cr, workitem, activity["split_mode"], ident, signal, stack) triggers = triggers and not ok if triggers: cr.execute("select * from wkf_transition where act_from=%s", (workitem["act_id"],)) alltrans = cr.dictfetchall() for trans in alltrans: if trans["trigger_model"]: ids = wkf_expr._eval_expr(cr, ident, workitem, trans["trigger_expr_id"]) for res_id in ids: cr.execute("select nextval('wkf_triggers_id_seq')") 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), ) return result
def process(cr, workitem, ident, signal=None, force_running=False, stack=None): """ Let the workitem do some work @param cr: database handle @param workitem: dict of the workitem to process @param ident: tuple of (uid, dotted model name, resource id ) @param signal: desired signal (or transition name) to follow upon complete this will filter the list of possible transitions to only that signal noted. @param force_running: @param stack: ??? A single workitem can only be associated with a single workflow state, this function will see if there are any actions that must be performed on this workitem. """ if stack is None: raise 'Error !!!' result = True cr.execute('select * from wkf_activity where id=%s', (workitem['act_id'], )) activity = cr.dictfetchone() if config['debug_workflow']: _logger.debug( "process {i[1]},{i[2]} workitem,{w[id]} {w[state]} -> {s}".format( w=workitem, i=ident, s=signal)) # If a workitem is "active" we will get the configured "activity" to execute # upon this information triggers = False if workitem['state'] == 'active': triggers = True result = _execute(cr, workitem, activity, ident, stack) if not result: return False # If a workitem is "running" it's doing something and we don't need to work # further on it. if workitem['state'] == 'running': pass # If a workitem is "complete", this means that all activity/code that has to run # on this code is done or the subflow is now also complete. This means we can # move to the next node if required. if workitem['state'] == 'complete' or force_running: ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack) triggers = triggers and not ok # WAT DO TRWIGGERS DO?? if triggers: cr.execute('select * from wkf_transition where act_from=%s', (workitem['act_id'], )) alltrans = cr.dictfetchall() for trans in alltrans: if trans['trigger_model']: ids = wkf_expr._eval_expr(cr, ident, workitem, trans['trigger_expr_id']) for res_id in ids: cr.execute('select nextval(\'wkf_triggers_id_seq\')') 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)) return result