Adding Graph Rendering Routine in the Trunk
bzr revid: fp@tinyerp.com-55457de5949ef31ba3aa2b82612f3911afed2ecf
This commit is contained in:
parent
e264704f58
commit
1e256fd373
|
@ -28,6 +28,7 @@
|
|||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
from tools import graph
|
||||
import netsvc
|
||||
|
||||
class workflow(osv.osv):
|
||||
|
@ -51,6 +52,32 @@ class workflow(osv.osv):
|
|||
wf_service.clear_cache(cr, user)
|
||||
return super(workflow, self).write(cr, user, ids, vals, context=context)
|
||||
|
||||
#
|
||||
# scale = [stepx, stepy, posx, posy ]
|
||||
#
|
||||
def graph_get(self, cr, uid, id, scale, context={}):
|
||||
nodes= []
|
||||
transitions = []
|
||||
start = []
|
||||
tres = []
|
||||
workflow = self.browse(cr, uid, id, context)
|
||||
for a in workflow.activities:
|
||||
nodes.append((a.id,a.name))
|
||||
if a.flow_start:
|
||||
start.append((a.id,a.name))
|
||||
for t in a.out_transitions:
|
||||
transitions.append( ((a.id,a.name), (t.act_to.id,t.act_to.name)) )
|
||||
tres.append((a.id,t.act_to.id))
|
||||
g = graph(nodes, transitions)
|
||||
g.process(start)
|
||||
g.scale(*scale)
|
||||
result = g.result_get()
|
||||
results = {}
|
||||
for r in result.items():
|
||||
r[1]['name'] = r[0][1]
|
||||
results[str(r[0][0])] = r[1]
|
||||
return {'node': results, 'transition': tres}
|
||||
|
||||
def create(self, cr, user, vals, context=None):
|
||||
if not context:
|
||||
context={}
|
||||
|
|
|
@ -2,3 +2,4 @@ from config import *
|
|||
from misc import *
|
||||
from convert import *
|
||||
from translate import *
|
||||
from graph import graph
|
||||
|
|
|
@ -58,7 +58,7 @@ class graph(object):
|
|||
def process(self, starting_node):
|
||||
pos = (len(starting_node) - 1.0)/2.0
|
||||
for s in starting_node:
|
||||
g.process_ranking(s)
|
||||
self.process_ranking(s)
|
||||
self.result[s]['x'] = pos
|
||||
pos += 1.0
|
||||
|
||||
|
|
Loading…
Reference in New Issue