Commit 81b94a7a authored by iv's avatar iv

ERP5Workflow: fix initialization of permissions on states

during workflow conversion
On DCWorkflow states, when the workflow does not manage permissions,
they may appear in some states's permission_roles dict.
This create wrong permissions, and we should not set them if they are
not managed by the workflow.
parent 782878ed
......@@ -381,6 +381,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
transition.setAfterScriptValueList(script_path_list)
# create states (portal_type = State)
workflow_managed_role_list = workflow.getManagedRoleList()
for sid in dc_workflow.states:
sdef = dc_workflow.states.get(sid)
state = workflow.newContent(portal_type='State', temp_object=is_temporary)
......@@ -395,15 +396,16 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
permission_roles_dict = {}
if sdef.permission_roles:
for (permission, roles) in sdef.permission_roles.items():
if permission in dc_workflow.permissions:
if isinstance(roles, list): # type 'list' means acquisition
acquire_permission_list.append(permission)
permission_roles_dict[permission] = list(roles)
state.setAcquirePermission(acquire_permission_list)
state.setStatePermissionRolesDict(permission_roles_dict)
if permission_roles_dict:
state.setCellRange(sorted(permission_roles_dict.keys()),
sorted(workflow.getManagedRoleList()),
sorted(workflow_managed_role_list),
base_id='cell')
# default state using category setter
......
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