Commit 19033e94 authored by Jérome Perrin's avatar Jérome Perrin

graph_editor: more robust BusinessProcess_getGraph

 - use relative url as key, not id/reference as it's not unique enough
 - support business link using non existent trade state ( for missing
paths in business template)
parent d181977c
......@@ -18,7 +18,7 @@ def getBusinessProcessGraph(business_process):
for trade_state in portal.portal_categories.trade_state.getCategoryChildValueList(): # XXX do we really want to display all trade states ?
state_id = trade_state.getReference() or trade_state.getId()
state_id = trade_state.getRelativeUrl()
graph['node'][state_id] = dict(
_class='erp5.business_process.trade_state',
name=trade_state.getTranslatedTitle())
......@@ -32,12 +32,17 @@ def getBusinessProcessGraph(business_process):
visited_business_process_set.add(business_process)
for link in business_process.contentValues(portal_type='Business Link'):
predecessor = 'start'
if link.getPredecessor():
predecessor = link.getPredecessorReference() or link.getPredecessorId()
successor = 'end'
if link.getSuccessor():
successor = link.getSuccessorReference() or link.getSuccessorId()
predecessor = link.getPredecessor() or 'start'
if predecessor not in graph['node']:
graph['node'][predecessor] = dict(
_class='erp5.business_process.trade_state',
name="missing trade state %s" % predecessor)
successor = link.getSuccessor() or 'end'
if successor not in graph['node']:
graph['node'][predecessor] = dict(
_class='erp5.business_process.trade_state',
name="missing trade state %s" % successor)
graph['edge'][link.getRelativeUrl()] = dict(
_class='erp5.business_process.business_link',
......@@ -64,7 +69,7 @@ class_definition = {
'properties': {
'name': {'type': 'string', 'name': str(translateString('Name'))},
'trade_phase': {'type': 'string', 'name': str(translateString('Trade Phase')), 'enum': [''] + [
trade_phase.getId() for trade_phase in portal.portal_categories.trade_phase.getCategoryChildValueList(local_sort_on=('int_index', 'title'))]},
trade_phase.getRelativeUrl() for trade_phase in portal.portal_categories.trade_phase.getCategoryChildValueList(local_sort_on=('int_index', 'title'))]},
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment