Commit a9d81b09 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_core] fixup document deletion dialog

Some document subobjects have a workflow, and so, can be only be deleted from some state
If the listbox does not display them, do not add the state filter parameter
parent 1fdf9ede
......@@ -64,6 +64,10 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value>
......@@ -80,6 +84,14 @@
<key> <string>lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>list_method</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>select</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string></string> </value>
......@@ -145,7 +157,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: field.getTemplateField().get_value(\'default_params\') + here.Module_listWorkflowTransitionItemList()[\'listbox_parameter_dict\'][\'delete_action\']</string> </value>
<value> <string>python: here.Folder_getDeletableDocumentListParameterList(field)</string> </value>
</item>
</dictionary>
</pickle>
......
parameter_list = field.getTemplateField().get_value('default_params')
# Some document subobjects have a workflow, and so, can be only be deleted from some state
# If the listbox does not display them, do not add the state filter parameter
filter_portal_type_list = [x[1] for x in parameter_list if x[0] == 'portal_type']
if filter_portal_type_list:
if sametype(filter_portal_type_list, ''):
filter_portal_type_list = [filter_portal_type_list]
else:
filter_portal_type_list = None
return parameter_list + context.Module_listWorkflowTransitionItemList(filter_portal_type_list=filter_portal_type_list)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>field</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Folder_getDeletableDocumentListParameterList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -19,6 +19,8 @@ module_portal_type = type_tool.getTypeInfo(module)
checked_workflow_id_dict = {}
for document_portal_type_id in module_portal_type.getTypeAllowedContentTypeList():
if (filter_portal_type_list is not None) and (filter_portal_type_list not in portal_type_list):
continue
for workflow in workflow_tool.getWorkflowsFor(document_portal_type_id):
if workflow.id not in checked_workflow_id_dict:
# Do not check the same workflow twice
......
......@@ -56,7 +56,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>filter_portal_type_list=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
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