Merge lp:~openerp-dev/openobject-server/6.0-bug-405962-pydot-vmt into lp:openobject-server/6.0

Proposed by Vo Minh Thu
Status: Merged
Merged at revision: 3355
Proposed branch: lp:~openerp-dev/openobject-server/6.0-bug-405962-pydot-vmt
Merge into: lp:openobject-server/6.0
Diff against target: 65 lines (+22/-8)
1 file modified
bin/addons/base/ir/workflow/print_instance.py (+22/-8)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-bug-405962-pydot-vmt
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Approve
Review via email: mp+51521@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

I think graph_get() is called by client directly (e.g. for rendering diagram views) so the non-backwards API change is going to cause trouble there. The rest seems ok.

review: Needs Fixing
Revision history for this message
Vo Minh Thu (thu) wrote :

The graph_get() method called by the clients is on ir.ui.view only. So no problem here.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

After reviewing the graphs, we should still fix the labels for subflows that are already expanded in the graph, as "Recursive Subflow:" is perhaps not the most intuitive explanation for end-users.
As discussed, we could append a line like "(see other already expanded call to this subflow)" at the end of the label -- or something shorter.

Thanks!

3354. By Vo Minh Thu

[FIX] workflow/print: changed wording for recursive cluster representation.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/base/ir/workflow/print_instance.py'
2--- bin/addons/base/ir/workflow/print_instance.py 2011-01-12 08:54:42 +0000
3+++ bin/addons/base/ir/workflow/print_instance.py 2011-03-03 12:58:49 +0000
4@@ -25,7 +25,7 @@
5 import report,pooler,tools
6 from operator import itemgetter
7
8-def graph_get(cr, graph, wkf_ids, nested=False, workitem={}):
9+def graph_get(cr, graph, wkf_ids, nested, workitem, processed_subflows):
10 import pydot
11 cr.execute('select * from wkf_activity where wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
12 nodes = cr.dictfetchall()
13@@ -34,11 +34,12 @@
14 actto = {}
15 for n in nodes:
16 activities[n['id']] = n
17- if n['subflow_id'] and nested:
18+ if n['subflow_id'] and nested and n['subflow_id'] not in processed_subflows:
19+ processed_subflows.add(n['subflow_id']) # don't create multiple times the same cluster.
20 cr.execute('select * from wkf where id=%s', (n['subflow_id'],))
21 wkfinfo = cr.dictfetchone()
22- graph2 = pydot.Cluster('subflow'+str(n['subflow_id']), fontsize='12', label = """\"Subflow: %s\\nOSV: %s\"""" % ( n['name'], wkfinfo['osv']) )
23- (s1,s2) = graph_get(cr, graph2, [n['subflow_id']], nested,workitem)
24+ graph2 = pydot.Cluster('subflow'+str(n['subflow_id']), fontsize='12', label = "\"Subflow: %s\\nOSV: %s\"" % ( n['name'], wkfinfo['osv']) )
25+ (s1,s2) = graph_get(cr, graph2, [n['subflow_id']], True, workitem, processed_subflows)
26 graph.add_subgraph(graph2)
27 actfrom[n['id']] = s2
28 actto[n['id']] = s1
29@@ -48,11 +49,22 @@
30 args['style']='filled'
31 args['color']='lightgrey'
32 args['label']=n['name']
33+ workitems = ''
34+ if n['id'] in workitem:
35+ workitems = '\\nx ' + str(workitem[n['id']])
36+ args['label'] += workitems
37+ args['color'] = "red"
38+ args['style']='filled'
39 if n['subflow_id']:
40 args['shape'] = 'box'
41- if n['id'] in workitem:
42- args['label']+='\\nx '+str(workitem[n['id']])
43- args['color'] = "red"
44+ if nested and n['subflow_id'] in processed_subflows:
45+ cr.execute('select * from wkf where id=%s', (n['subflow_id'],))
46+ wkfinfo = cr.dictfetchone()
47+ args['label'] = \
48+ '\"Subflow: %s\\nOSV: %s\\n(already expanded)%s\"' % \
49+ (n['name'], wkfinfo['osv'], workitems)
50+ args['color'] = 'green'
51+ args['style'] ='filled'
52 graph.add_node(pydot.Node(n['id'], **args))
53 actfrom[n['id']] = (n['id'],{})
54 actto[n['id']] = (n['id'],{})
55@@ -104,7 +116,9 @@
56 for (subflow_id,) in cr.fetchall():
57 workitems.update(workitem_get(subflow_id))
58 return workitems
59- graph_get(cr, graph, [x[0] for x in inst], nested, workitem_get(inst_id))
60+
61+ processed_subflows = set()
62+ graph_get(cr, graph, [x[0] for x in inst], nested, workitem_get(inst_id), processed_subflows)
63
64 #
65 # TODO: pas clean: concurrent !!!