summaryrefslogtreecommitdiff
path: root/bin/addons/base/ir/workflow
diff options
context:
space:
mode:
authorvra <vra@tinyerp.com>2010-06-24 14:16:50 +0530
committervra <vra@tinyerp.com>2010-06-24 14:16:50 +0530
commit7ed648ce889dfeaa9045602fad7dca555095e9d4 (patch)
tree9dc3dffd579a27ace5529179b203c41227d3e19e /bin/addons/base/ir/workflow
parentb311f12e2a697bfaad7582aff9ac6502129e9a61 (diff)
parent5696ed3785c80671b38fd196584786482d293dea (diff)
[MERGE] merge the changes from main trunk branch.
bzr revid: vra@tinyerp.com-20100624084539-ne1e1tscqn1z3jw5 bzr revid: vra@tinyerp.com-20100624084650-svala4jb0dnf7aal
Diffstat (limited to 'bin/addons/base/ir/workflow')
-rw-r--r--bin/addons/base/ir/workflow/print_instance.py38
-rw-r--r--bin/addons/base/ir/workflow/workflow_view.xml2
2 files changed, 21 insertions, 19 deletions
diff --git a/bin/addons/base/ir/workflow/print_instance.py b/bin/addons/base/ir/workflow/print_instance.py
index 16a560b2457..259fe51d41a 100644
--- a/bin/addons/base/ir/workflow/print_instance.py
+++ b/bin/addons/base/ir/workflow/print_instance.py
@@ -25,9 +25,9 @@ import netsvc
import report,pooler,tools
from operator import itemgetter
-def graph_get(cr, graph, wkf_id, nested=False, workitem={}):
+def graph_get(cr, graph, wkf_ids, nested=False, workitem={}):
import pydot
- cr.execute('select * from wkf_activity where wkf_id=%s', (wkf_id,))
+ cr.execute('select * from wkf_activity where wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
nodes = cr.dictfetchall()
activities = {}
actfrom = {}
@@ -60,6 +60,8 @@ def graph_get(cr, graph, wkf_id, nested=False, workitem={}):
cr.execute('select * from wkf_transition where act_from IN %s', (node_ids,))
transitions = cr.dictfetchall()
for t in transitions:
+ if not t['act_to'] in activities:
+ continue
args = {}
args['label'] = str(t['condition']).replace(' or ', '\\nor ').replace(' and ', '\\nand ')
if t['signal']:
@@ -78,9 +80,9 @@ def graph_get(cr, graph, wkf_id, nested=False, workitem={}):
activity_to = actto[t['act_to']][1].get(t['signal'], actto[t['act_to']][0])
graph.add_edge(pydot.Edge( str(activity_from) ,str(activity_to), fontsize='10', **args))
nodes = cr.dictfetchall()
- cr.execute('select id from wkf_activity where flow_start=True and wkf_id=%s limit 1', (wkf_id,))
+ cr.execute('select * from wkf_activity where flow_start=True and wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
start = cr.fetchone()[0]
- cr.execute("select 'subflow.'||name,id from wkf_activity where flow_stop=True and wkf_id=%s", (wkf_id,))
+ cr.execute("select 'subflow.'||name,id from wkf_activity where flow_stop=True and wkf_id in ("+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
stop = cr.fetchall()
if (stop):
stop = (stop[0][1], dict(stop))
@@ -91,8 +93,8 @@ def graph_get(cr, graph, wkf_id, nested=False, workitem={}):
def graph_instance_get(cr, graph, inst_id, nested=False):
workitems = {}
- cr.execute('select * from wkf_instance where id=%s', (inst_id,))
- inst = cr.dictfetchone()
+ cr.execute('select wkf_id from wkf_instance where id=%s', (inst_id,))
+ inst = cr.fetchall()
def workitem_get(instance):
cr.execute('select act_id,count(*) from wkf_workitem where inst_id=%s group by act_id', (instance,))
@@ -102,7 +104,7 @@ def graph_instance_get(cr, graph, inst_id, nested=False):
for (subflow_id,) in cr.fetchall():
workitems.update(workitem_get(subflow_id))
return workitems
- graph_get(cr, graph, inst['wkf_id'], nested, workitem_get(inst_id))
+ graph_get(cr, graph, [x[0] for x in inst], nested, workitem_get(inst_id))
#
# TODO: pas clean: concurrent !!!
@@ -132,12 +134,9 @@ class report_graph_instance(object):
(No workflow defined) show
showpage'''
else:
- cr.execute('SELECT id FROM wkf_instance \
- WHERE res_id=%s AND wkf_id=%s \
- ORDER BY state LIMIT 1',
- (data['id'], wkfinfo['id']))
- inst_id = cr.fetchone()
- if not inst_id:
+ cr.execute('select i.id from wkf_instance i left join wkf w on (i.wkf_id=w.id) where res_id=%s and osv=%s',(data['id'],data['model']))
+ inst_ids = cr.fetchall()
+ if not inst_ids:
ps_string = '''%PS-Adobe-3.0
/inch {72 mul} def
/Times-Roman findfont 50 scalefont setfont
@@ -145,11 +144,14 @@ showpage'''
(No workflow instance defined) show
showpage'''
else:
- inst_id = inst_id[0]
- graph = pydot.Dot(fontsize='16', label="""\\\n\\nWorkflow: %s\\n OSV: %s""" % (wkfinfo['name'],wkfinfo['osv']),
- size='7.3, 10.1', center='1', ratio='auto', rotate='0', rankdir='TB',
- )
- graph_instance_get(cr, graph, inst_id, data.get('nested', False))
+ graph = pydot.Dot(
+ fontsize='16',
+ label="""\\\n\\nWorkflow: %s\\n OSV: %s""" % (wkfinfo['name'],wkfinfo['osv']),
+ size='7.3, 10.1', center='1', ratio='auto', rotate='0', rankdir='TB',
+ )
+ for inst_id in inst_ids:
+ inst_id = inst_id[0]
+ graph_instance_get(cr, graph, inst_id, data.get('nested', False))
ps_string = graph.create(prog='dot', format='ps')
except Exception, e:
import traceback, sys
diff --git a/bin/addons/base/ir/workflow/workflow_view.xml b/bin/addons/base/ir/workflow/workflow_view.xml
index f6bfc0096f1..8713bb50698 100644
--- a/bin/addons/base/ir/workflow/workflow_view.xml
+++ b/bin/addons/base/ir/workflow/workflow_view.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
- <menuitem id="menu_workflow_root" name="Workflow Definitions" parent="menu_custom"/>
+ <menuitem id="menu_workflow_root" name="Workflow Definitions" parent="base.menu_custom" groups="base.group_extended"/>
<!--
================================