From 1e256fd373a318728c17bf2c292bfc9c8054d766 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 21 Apr 2008 07:09:08 +0000 Subject: [PATCH 1/1] Adding Graph Rendering Routine in the Trunk bzr revid: fp@tinyerp.com-55457de5949ef31ba3aa2b82612f3911afed2ecf --- bin/addons/base/ir/workflow/workflow.py | 27 +++++++++++++++++++++++++++ bin/tools/__init__.py | 1 + bin/tools/graph.py | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/bin/addons/base/ir/workflow/workflow.py b/bin/addons/base/ir/workflow/workflow.py index f40093d..886688f 100644 --- a/bin/addons/base/ir/workflow/workflow.py +++ b/bin/addons/base/ir/workflow/workflow.py @@ -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={} diff --git a/bin/tools/__init__.py b/bin/tools/__init__.py index 455a321..6088f5e 100644 --- a/bin/tools/__init__.py +++ b/bin/tools/__init__.py @@ -2,3 +2,4 @@ from config import * from misc import * from convert import * from translate import * +from graph import graph diff --git a/bin/tools/graph.py b/bin/tools/graph.py index 25cbd9b..6dde9ee 100644 --- a/bin/tools/graph.py +++ b/bin/tools/graph.py @@ -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 -- 1.7.10.4