Commit b9942ff9 authored by wenjie.zheng's avatar wenjie.zheng

erp5_workflow: script to reassign workflow when there is a new bt installation...

erp5_workflow: script to reassign workflow when there is a new bt installation after workflow conversion which may bring old assignment in chain_by_type with converted workflow ids.
parent 5a96d70b
<?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>_body</string> </key>
<value> <string>"""\n
This script should be called in following case:\n
- new business installation after workflow conversion;\n
- workflow assignement in _chain_by_type with converted workflows\' id coming with this new installed bt.\n
"""\n
\n
workflow_tool = context.getPortalObject().portal_workflow\n
type_workflow_dict = workflow_tool.getChainsByType()\n
\n
for ptype_id in type_workflow_dict:\n
ptype = getattr(context.getPortalObject().portal_types, ptype_id, None)\n
if ptype is not None:\n
for workflow_id in type_workflow_dict[ptype_id]:\n
workflow = getattr(workflow_tool, workflow_id, None)\n
if workflow and workflow.getPortalType() in [\'Workflow\', \'Interaction Workflow\']:\n
# 1. clean DC workflow assignement:\n
workflow_tool.delTypeCBT(ptype.id, workflow.id)\n
# 2. assign ERP5 Workflow to portal type:\n
type_workflow_list = ptype.getTypeWorkflowList()\n
if workflow_id not in type_workflow_list:\n
ptype.addTypeWorkflowList(workflow_id)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>reassign_workflow_please</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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