diff --git a/trytond/module.py b/trytond/module.py index a20f68198e..e981a02132 100644 --- a/trytond/module.py +++ b/trytond/module.py @@ -14,14 +14,9 @@ sys.path.insert(1, MODULES_PATH) class Graph(dict): def add_node(self, name, deps): - max_depth, father = 0, None for i in [Node(x, self) for x in deps]: - if i.depth >= max_depth: - father = i - max_depth = i.depth - if father: - father.add_child(name) - else: + i.add_child(name) + if not deps: Node(name, self) def __iter__(self): @@ -69,14 +64,21 @@ class Node(Singleton): def add_child(self, name): node = Node(name, self.graph) - node.depth = self.depth + 1 - if node not in self.childs: + node.depth = max(self.depth + 1, node.depth) + if node not in self.all_childs(): self.childs.append(node) for attr in ('init', 'update'): if hasattr(self, attr): setattr(node, attr, True) self.childs.sort(lambda x, y: cmp(x.name, y.name)) + def all_childs(self): + res = [] + for child in self.childs: + res.append(child) + res += child.all_childs() + return res + def has_child(self, name): return Node(name, self.graph) in self.childs or \ bool([c for c in self.childs if c.has_child(name)]) diff --git a/trytond/workflow/workflow.py b/trytond/workflow/workflow.py index 0213d59d06..b81f412b7d 100644 --- a/trytond/workflow/workflow.py +++ b/trytond/workflow/workflow.py @@ -220,7 +220,7 @@ class InstanceGraph(Report): inpt.close() data = outpt.read() outpt.close() - return ('pdf', base64.encodestring(data)) + return ('pdf', base64.encodestring(data), False) def graph_instance_get(self, cursor, user, graph, instance_id, nested=False, context=None):