Commit 37fbef7d authored by Xiaowu Zhang's avatar Xiaowu Zhang

product/Workflow&erp5_workflow_test: fix can't access workflow state after change State Variable

we have such error:
....
if context.getValidationState() in ["draft", "deleted", "cancelled", "archived"]:
  Module Products.ERP5Type.Accessor.WorkflowState, line 60, in __call__
    return wf._getWorkflowStateOf(instance, id_only=1)
  Module Products.ERP5Type.Core.Workflow, line 609, in _getWorkflowStateOf
    state_id = 'state_' + status.get(self.getStateVariable(), None)
TypeError: cannot concatenate 'str' and 'NoneType' objects
parent 5b130a47
...@@ -14,6 +14,7 @@ class TestERP5WorkflowMixin(TestWorkflowMixin): ...@@ -14,6 +14,7 @@ class TestERP5WorkflowMixin(TestWorkflowMixin):
module = self.portal.workflow_test_module module = self.portal.workflow_test_module
module.manage_delObjects(list(module.objectIds())) module.manage_delObjects(list(module.objectIds()))
self.portal.portal_workflow[self.initial_dc_workflow_id].setStateVariable('validation_state')
self.copyWorkflow(self.portal.portal_workflow, self.initial_dc_workflow_id, self.workflow_id) self.copyWorkflow(self.portal.portal_workflow, self.initial_dc_workflow_id, self.workflow_id)
self.copyWorkflow(self.portal.portal_workflow, self.initial_dc_interaction_workflow_id, self.interaction_workflow_id) self.copyWorkflow(self.portal.portal_workflow, self.initial_dc_interaction_workflow_id, self.interaction_workflow_id)
...@@ -191,6 +192,16 @@ class TestERP5WorkflowMixin(TestWorkflowMixin): ...@@ -191,6 +192,16 @@ class TestERP5WorkflowMixin(TestWorkflowMixin):
self.checkDocumentState(new_object, 'validated') self.checkDocumentState(new_object, 'validated')
self.assertEqual(workflow_tool.isTransitionPossible(new_object, 'invalidate'), 1) self.assertEqual(workflow_tool.isTransitionPossible(new_object, 'invalidate'), 1)
def test_13_testAccessWorkflowStateAfterChangeStateVariable(self):
new_object = self.getTestObject()
self.tic()
self.assertEqual(new_object.getValidationState(), 'draft')
self.portal.portal_workflow[self.initial_dc_workflow_id].setStateVariable('simulation_state')
self.portal.portal_workflow[self.workflow_id].setStateVariable('simulation_state')
self.tic()
self.assertEqual(new_object.getSimulationState(), 'draft')
self.tic()
class TestConvertedWorkflow(TestERP5WorkflowMixin): class TestConvertedWorkflow(TestERP5WorkflowMixin):
""" """
Tests Converted Workflow which generated dynamically from DCWorkflow. Tests Converted Workflow which generated dynamically from DCWorkflow.
......
...@@ -606,9 +606,11 @@ class Workflow(XMLObject): ...@@ -606,9 +606,11 @@ class Workflow(XMLObject):
if status is None: if status is None:
state = self.getSourceValue() state = self.getSourceValue()
else: else:
state_id = 'state_' + status.get(self.getStateVariable(), None) state_parameter = status.get(self.getStateVariable(), None)
if state_parameter:
state_id = 'state_' + state_parameter
state = self._getOb(state_id) state = self._getOb(state_id)
if state is None: if (state_parameter is None) or (state is None):
state = self.getSourceValue() state = self.getSourceValue()
if id_only: if id_only:
if state is None: if state is None:
......
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