Commit 6c8accf3 authored by Georgios Dagkakis's avatar Georgios Dagkakis

erp5_hal_json_style: Fix condition in Base_deleteObject to be similar to what

is used in Folder_delete, in order to decide if we would delete the object from ZODB
or do workflow transition.

Previous code was not harmful, since isDeletable check above would block
the case of existing workflow with 'delete_action' not possible in current state.
Yet, it was confusing.

/reviewed-on !696
parent aeb5c58d
......@@ -13,11 +13,18 @@ translate = portal.Base_translateString
if context.isDeletable(check_relation=True):
parent = context.getParentValue()
try:
if parent.portal_type != 'Preference' and \
portal.portal_workflow.isTransitionPossible(context, 'delete'):
portal.portal_workflow.doActionFor(context, 'delete_action')
history_dict = context.Base_getWorkflowHistory()
history_dict.pop('edit_workflow', None)
if history_dict == {} or context.aq_parent.portal_type == 'Preference':
# Objects that have no workflow history and
# templates inside preference will be unconditionnaly physically deleted
parent.manage_delObjects(ids=[context.getId()])
else:
parent.manage_delObjects(ids= [context.getId()])
# If a workflow manage a history,
# object should not be removed, but only put in state deleted
# No need to check if the action is possible,
# isDeletable would return False in other case
portal.portal_workflow.doActionFor(context, 'delete_action')
# redirect back to the container since the context was deleted
return parent.Base_redirect(
keep_items={
......
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