Commit c4ade4da authored by iv's avatar iv

ERP5Workflow: fix setting after scripts when converting workflow

parent ed25a9bf
......@@ -257,7 +257,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
temp_workflow_id_list.append(temp_workflow.getTitle())
return temp_workflow_list
def initialize_script_categories(self, workflow, initial_script_name_list, method):
def getScriptPathList(self, workflow, initial_script_name_list):
script_path_list = []
if isinstance(initial_script_name_list, str):
initial_script_name_list = [initial_script_name_list]
......@@ -267,7 +267,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
getattr(workflow, 'transition_' + script_name, None)
script_path = script.getRelativeUrl()
script_path_list.append(script_path)
method(tuple(script_path_list))
return script_path_list
def dc_workflow_asERP5Object(self, dc_workflow, is_temporary=False):
""" convert DC Workflow to New Workflow """
......@@ -351,11 +351,14 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# we have to loop again over transitions because some
# before/after/... scripts are transitions and obviously, all of
# them were not defined on the new workflow in the previous loop
old_transition = dc_workflow_transition_value_list.get(transition.getReference())
script_path_list = self.getScriptPathList(workflow,
old_transition.script_name)
transition.setBeforeScriptValueList(script_path_list)
self.initialize_script_categories(workflow, tdef.script_name,
transition.setBeforeScriptValueList)
self.initialize_script_categories(workflow, tdef.after_script_name,
transition.setAfterScriptValueList)
script_path_list = self.getScriptPathList(workflow,
old_transition.after_script_name)
transition.setAfterScriptValueList(script_path_list)
# create states (portal_type = State)
for sid in dc_workflow.states:
......@@ -461,14 +464,21 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# configure after/before/before commit/activate scripts
# no need to loop again over interactions as made for transitions
# because interactions xxx_script are not interactions
self.initialize_script_categories(workflow, tdef.script_name,
interaction.setBeforeScriptValueList)
self.initialize_script_categories(workflow, tdef.after_script_name,
interaction.setAfterScriptValueList)
self.initialize_script_categories(workflow, tdef.activate_script_name,
interaction.setActivateScriptValueList)
self.initialize_script_categories(workflow, tdef.before_commit_script_name,
interaction.setBeforeCommitScriptValueList)
script_path_list = self.getScriptPathList(workflow,
tdef.script_name)
interaction.setBeforeScriptValueList(script_path_list)
script_path_list = self.getScriptPathList(workflow,
tdef.after_script_name)
interaction.setAfterScriptValueList(script_path_list)
script_path_list = self.getScriptPathList(workflow,
tdef.activate_script_name)
interaction.setActivateScriptValueList(script_path_list)
script_path_list = self.getScriptPathList(workflow,
tdef.before_commit_script_name)
interaction.setBeforeCommitScriptValueList(script_path_list)
# configure guard
if tdef.guard:
......
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