Code review comment for lp:~rvalyi/openobject-addons/extensible-mrp

Revision history for this message
Harry (OpenERP) (hmo-tinyerp) wrote :

#problem: workflow is generated error if return not integer value. procurement has subflow and workflow engine has need new resource id to call subflow.
worflow should support dict or list of new created resources to call subflow.

here problem occured from workflow engine if return non integer value from workflow action: ( when I try to return list of new created resources)
-------------
[2010-03-17 17:11:27,586] ERROR:web-services:[36]: File "/media/disk/hmo/Office/Projects/OpenERP/openobject-server/bin/workflow/workitem.py", line 53, in process
[2010-03-17 17:11:27,586] ERROR:web-services:[37]: result = _execute(cr, workitem, activity, ident, stack)
[2010-03-17 17:11:27,586] ERROR:web-services:[38]: File "/media/disk/hmo/Office/Projects/OpenERP/openobject-server/bin/workflow/workitem.py", line 130, in _execute
[2010-03-17 17:11:27,586] ERROR:web-services:[39]: assert type(id_new)==type(1) or type(id_new)==type(1L), 'Wrong return value: '+str(id_new)+' '+str(type(id_new))
[2010-03-17 17:11:27,586] ERROR:web-services:[40]: AssertionError: Wrong return value: [7L] <type 'list'>
-----------------------
code in workflow/workitem.py:

....
...
...
elif activity['kind']=='subflow':
        if workitem['state']=='active':
            _state_set(cr, workitem, activity, 'running', ident)
            if activity.get('action', False):
                id_new = wkf_expr.execute(cr, ident, workitem, activity)
                if not (id_new):
                    cr.execute('delete from wkf_workitem where id=%s', (workitem['id'],))
                    return False
                assert type(id_new)==type(1) or type(id_new)==type(1L), 'Wrong return value: '+str(id_new)+' '+str(type(id_new))
                cr.execute('select id from wkf_instance where res_id=%s and wkf_id=%s', (id_new,activity['subflow_id']))
                id_new = cr.fetchone()[0]
            else:
                id_new = instance.create(cr, ident, activity['subflow_id'])
            cr.execute('update wkf_workitem set subflow_id=%s where id=%s', (id_new, workitem['id']))
            workitem['subflow_id'] = id_new
        if workitem['state']=='running':
            cr.execute("select state from wkf_instance where id=%s", (workitem['subflow_id'],))
            state= cr.fetchone()[0]
            if state=='complete':
                _state_set(cr, workitem, activity, 'complete', ident)

....
....
...

sorry I'm not expert in workflow engine but I'm think to support list or dict in this case.

Thanks to listen me.

« Back to merge proposal