Commit 3a3c4e58 authored by Jérome Perrin's avatar Jérome Perrin

Add Workflow Factory for ERP5-style workflow with all workflow variables for Base_viewHistory

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6499 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7f9a2918
......@@ -313,3 +313,68 @@ def getAvailableScriptIds(self):
self.getWorkflow().transitions[k].trigger_type == TRIGGER_WORKFLOW_METHOD]
TransitionDefinition.getAvailableScriptIds = getAvailableScriptIds
# Add a workflow factory for ERP5 style workflow, because some variables
# are needed for History tab.
from Products.CMFCore.WorkflowTool import addWorkflowFactory
from Products.ERP5Type import Permissions
def setupERP5Workflow(wf):
"""Sets up an DC Workflow with defaults variables needed by ERP5.
"""
wf.setProperties(title='ERP5 default workflow')
for s in ('draft',):
wf.states.addState(s)
for v in ('action', 'actor', 'comment', 'history', 'time',
'error_message'):
wf.variables.addVariable(v)
for perm in (Permissions.AccessContentsInformation,
Permissions.View,
Permissions.ModifyPortalContent ):
wf.addManagedPermission(perm)
wf.states.setInitialState('draft')
# set by default the state variable to simulation_state.
# anyway, a default workflow needs to be configured.
wf.variables.setStateVar('simulation_state')
vdef = wf.variables['action']
vdef.setProperties(description='The last transition',
default_expr='transition/getId|nothing',
for_status=1, update_always=1)
vdef = wf.variables['actor']
vdef.setProperties(description='The name of the user who performed '
'the last transition',
default_expr='user/getUserName',
for_status=1, update_always=1)
vdef = wf.variables['comment']
vdef.setProperties(description='Comments about the last transition',
default_expr="python:state_change.kwargs.get('comment', '')",
for_status=1, update_always=1)
vdef = wf.variables['history']
vdef.setProperties(description='Provides access to workflow history',
default_expr="state_change/getHistory")
vdef = wf.variables['time']
vdef.setProperties(description='Time of the last transition',
default_expr="state_change/getDateTime",
for_status=1, update_always=1)
vdef = wf.variables['error_message']
vdef.setProperties(description='Error message if validation failed',
for_status=1, update_always=1)
def createERP5Workflow(id):
"""Creates an ERP5 Workflow """
ob = DCWorkflowDefinition(id)
setupERP5Workflow(ob)
return ob
addWorkflowFactory(createERP5Workflow,
id='erp5_workflow',
title='ERP5-style empty workflow')
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