Commit 1a3eddad authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Julien Muchembled

erp5_core: fix KeyError: '..._action' in Module_listWorkflowTransitionItemList

When a workflow transition was not used by any state,
calling some_module.Module_listWorkflowTransitionItemList was raising:
    [..]
      Module script, line 49, in Module_listWorkflowTransitionItemList
       - <PythonScript at /tsxx/Module_listWorkflowTransitionItemList used for /tsxx/some_module>
       - Line 49
        result['listbox_parameter_dict'][transition_id] = [(state_variable, allowed_state_dict[transition_id])]
      Module AccessControl.ZopeGuards, line 83, in guarded_getitem
        v = object[index]
    KeyError: 'some_action'

Now, pick transition among the allowed_state_dict instead of workflow.transitions.

This also fixes mass change state dialog "??? ()" issue.
This commit adds a transition that allows to reproduce that issue.
And this line covers the case :
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testMassWorkflowTransition.zpt (line 61)

/reviewed-on nexedi/erp5!788
parent 1b94a641
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string>Please Do Nothing</string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=noop_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>noop_action</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Do Nothing</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>Modify portal content</string>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -36,7 +36,7 @@ for document_portal_type_id in module_portal_type.getTypeAllowedContentTypeList(
else:
allowed_state_dict[possible_transition_id] = [state_id]
for transition_id in workflow.transitions:
for transition_id in allowed_state_dict:
transition = workflow.transitions[transition_id]
# Only display user action transition with a dialog to show to user
if (transition.trigger_type == TRIGGER_USER_ACTION) and (transition.actbox_url) and (transition.actbox_name):
......
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