diff options
| author | ced <> | 2007-09-20 08:48:10 +0000 |
|---|---|---|
| committer | ced <> | 2007-09-20 08:48:10 +0000 |
| commit | e318310d8c868e79f9f3ddc762b5b10af8d943cd (patch) | |
| tree | 4ffc73c5080ba354d2ecd40b78654d48b7fa61b8 /bin/addons/base/ir/workflow/print_instance.py | |
| parent | 1f37d69d4801aa8619fd061af3657bb50585cd20 (diff) | |
Remove error when printing workflow on object that don't have one
bzr revid: ced-5cd0cb26db35d4a276acb2030c39e4be3f86d84f
Diffstat (limited to 'bin/addons/base/ir/workflow/print_instance.py')
| -rw-r--r-- | bin/addons/base/ir/workflow/print_instance.py | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/bin/addons/base/ir/workflow/print_instance.py b/bin/addons/base/ir/workflow/print_instance.py index 97daabded26..0ad2a408acb 100644 --- a/bin/addons/base/ir/workflow/print_instance.py +++ b/bin/addons/base/ir/workflow/print_instance.py @@ -117,24 +117,46 @@ class report_graph_instance(object): try: import pydot except Exception,e: - logger.notifyChannel('workflow', netsvc.LOG_WARNING, 'Import Error for pydot, you will not be able to render workflows\nConsider Installing PyDot or dependencies: http://dkbza.org/pydot.html') + logger.notifyChannel('workflow', netsvc.LOG_WARNING, + 'Import Error for pydot, you will not be able to render workflows\n' + 'Consider Installing PyDot or dependencies: http://dkbza.org/pydot.html') raise e self.done = False try: - cr.execute('select * from wkf where osv=%s limit 1', (data['model'],)) + cr.execute('select * from wkf where osv=%s limit 1', + (data['model'],)) wkfinfo = cr.dictfetchone() - cr.execute('select id from wkf_instance where res_id=%d and wkf_id=%d order by state limit 1', (data['id'],wkfinfo['id'])) - inst_id = cr.fetchone()[0] - - graph = pydot.Dot(fontsize=16, label="\\n\\nWorkflow: %s\\n OSV: %s" % (wkfinfo['name'],wkfinfo['osv'])) - graph.set('size', '10.7,7.3') - graph.set('center', '1') - graph.set('ratio', 'auto') - graph.set('rotate', '90') - graph.set('rankdir', 'LR') - graph_instance_get(cr, graph, inst_id, data.get('nested', False)) - ps_string = graph.create_ps(prog='dot') + if not wkfinfo: + ps_string = '''%PS-Adobe-3.0 +/inch {72 mul} def +/Times-Roman findfont 50 scalefont setfont +1.5 inch 15 inch moveto +(No workflow defined) show +showpage''' + else: + cr.execute('SELECT id FROM wkf_instance \ + WHERE res_id=%d AND wkf_id=%d \ + ORDER BY state LIMIT 1', + (data['id'], wkfinfo['id'])) + inst_id = cr.fetchone() + if not inst_id: + ps_string = '''%PS-Adobe-3.0 +/inch {72 mul} def +/Times-Roman findfont 50 scalefont setfont +1.5 inch 15 inch moveto +(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'])) + graph.set('size', '10.7,7.3') + graph.set('center', '1') + graph.set('ratio', 'auto') + graph.set('rotate', '90') + graph.set('rankdir', 'LR') + graph_instance_get(cr, graph, inst_id, data.get('nested', False)) + ps_string = graph.create_ps(prog='dot') except Exception, e: import traceback, sys tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) |
