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
Pipeline #7031 passed with stage
in 0 seconds
......@@ -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)
  • shouldn't be parameter_list + context.Module_listWorkflowTransitionItemList(filter_portal_type_list=filter_portal_type_list)['listbox_parameter_dict']['delete_action'] ?

  • Probably. Too bad the tests do not catch this issue...

Please register or sign in to reply
<?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>
......
  • @romain can you please take a look at coding style test result while you remember this code ?

    What happened is that I enabled erp5_core in coding style test, I did this in !996 (merged) which started from a bit old revision, before this change. Now that !996 (merged) is merged, this introduced a failure:

    + [portal_skins/erp5_core/Folder_getDeletableDocumentListParameterList:6:7:Undefined variable 'sametype' (undefined-variable),
    +  portal_skins/erp5_core/Module_listWorkflowTransitionItemList:21:81:Undefined variable 'portal_type_list' (undefined-variable)]

    ( I thought that our pylint does not understand sametype, but the spelling seems to be same_type )

    merci !

  • mentioned in commit romain/erp5@556a6693

    Toggle commit list
  • mentioned in commit romain/erp5@8cab9253

    Toggle commit list
  • mentioned in commit 106ee51f

    Toggle commit list
  • @jerome sorry for the noise. It should be fixed now

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