From deb778b0296493814ddbac5d491c817ce252c2bf Mon Sep 17 00:00:00 2001
From: Wenjie Zheng <wenjie.zheng@tiolive.com>
Date: Thu, 30 Apr 2015 13:07:26 +0000
Subject: [PATCH] ERP5Site.py: Load ERP5 Workflow Tool to built the site
 instead of loading CMF Workflow Tool.

---
 .../interaction_workflows.xml                 | 157 ------------------
 .../workflows.xml                             | 157 ------------------
 product/ERP5/ERP5Site.py                      |   7 +-
 3 files changed, 4 insertions(+), 317 deletions(-)
 delete mode 100644 bt5/erp5_workflow/SkinTemplateItem/portal_skins/erp5_workflow/ERP5WorkflowTool_viewWorkflowList/interaction_workflows.xml
 delete mode 100644 bt5/erp5_workflow/SkinTemplateItem/portal_skins/erp5_workflow/ERP5WorkflowTool_viewWorkflowList/workflows.xml

diff --git a/bt5/erp5_workflow/SkinTemplateItem/portal_skins/erp5_workflow/ERP5WorkflowTool_viewWorkflowList/interaction_workflows.xml b/bt5/erp5_workflow/SkinTemplateItem/portal_skins/erp5_workflow/ERP5WorkflowTool_viewWorkflowList/interaction_workflows.xml
deleted file mode 100644
index 89451ec265..0000000000
--- a/bt5/erp5_workflow/SkinTemplateItem/portal_skins/erp5_workflow/ERP5WorkflowTool_viewWorkflowList/interaction_workflows.xml
+++ /dev/null
@@ -1,157 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>delegated_list</string> </key>
-            <value>
-              <list>
-                <string>columns</string>
-                <string>editable_columns</string>
-                <string>hide_rows_on_no_search_criterion</string>
-                <string>portal_types</string>
-                <string>selection_name</string>
-                <string>sort</string>
-                <string>title</string>
-              </list>
-            </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>interaction_workflows</string> </value>
-        </item>
-        <item>
-            <key> <string>message_values</string> </key>
-            <value>
-              <dictionary>
-                <item>
-                    <key> <string>external_validator_failed</string> </key>
-                    <value> <string>The input failed the external validator.</string> </value>
-                </item>
-              </dictionary>
-            </value>
-        </item>
-        <item>
-            <key> <string>overrides</string> </key>
-            <value>
-              <dictionary>
-                <item>
-                    <key> <string>field_id</string> </key>
-                    <value> <string></string> </value>
-                </item>
-                <item>
-                    <key> <string>form_id</string> </key>
-                    <value> <string></string> </value>
-                </item>
-                <item>
-                    <key> <string>target</string> </key>
-                    <value> <string></string> </value>
-                </item>
-              </dictionary>
-            </value>
-        </item>
-        <item>
-            <key> <string>tales</string> </key>
-            <value>
-              <dictionary>
-                <item>
-                    <key> <string>field_id</string> </key>
-                    <value> <string></string> </value>
-                </item>
-                <item>
-                    <key> <string>form_id</string> </key>
-                    <value> <string></string> </value>
-                </item>
-                <item>
-                    <key> <string>target</string> </key>
-                    <value> <string></string> </value>
-                </item>
-              </dictionary>
-            </value>
-        </item>
-        <item>
-            <key> <string>values</string> </key>
-            <value>
-              <dictionary>
-                <item>
-                    <key> <string>columns</string> </key>
-                    <value>
-                      <list>
-                        <tuple>
-                          <string>reference</string>
-                          <string>Reference</string>
-                        </tuple>
-                        <tuple>
-                          <string>title</string>
-                          <string>Title</string>
-                        </tuple>
-                        <tuple>
-                          <string>description</string>
-                          <string>Description</string>
-                        </tuple>
-                      </list>
-                    </value>
-                </item>
-                <item>
-                    <key> <string>editable_columns</string> </key>
-                    <value>
-                      <list/>
-                    </value>
-                </item>
-                <item>
-                    <key> <string>field_id</string> </key>
-                    <value> <string>my_list_mode_listbox</string> </value>
-                </item>
-                <item>
-                    <key> <string>form_id</string> </key>
-                    <value> <string>Base_viewFieldLibrary</string> </value>
-                </item>
-                <item>
-                    <key> <string>hide_rows_on_no_search_criterion</string> </key>
-                    <value> <int>0</int> </value>
-                </item>
-                <item>
-                    <key> <string>portal_types</string> </key>
-                    <value>
-                      <list>
-                        <tuple>
-                          <string>Interaction Workflow</string>
-                          <string>Interaction Workflow</string>
-                        </tuple>
-                      </list>
-                    </value>
-                </item>
-                <item>
-                    <key> <string>selection_name</string> </key>
-                    <value> <string>interaction_workflow_selection</string> </value>
-                </item>
-                <item>
-                    <key> <string>sort</string> </key>
-                    <value>
-                      <list>
-                        <tuple>
-                          <string>reference</string>
-                          <string>Reference</string>
-                        </tuple>
-                      </list>
-                    </value>
-                </item>
-                <item>
-                    <key> <string>target</string> </key>
-                    <value> <string>Click to edit the target</string> </value>
-                </item>
-                <item>
-                    <key> <string>title</string> </key>
-                    <value> <string>Interaction Workflows</string> </value>
-                </item>
-              </dictionary>
-            </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_workflow/SkinTemplateItem/portal_skins/erp5_workflow/ERP5WorkflowTool_viewWorkflowList/workflows.xml b/bt5/erp5_workflow/SkinTemplateItem/portal_skins/erp5_workflow/ERP5WorkflowTool_viewWorkflowList/workflows.xml
deleted file mode 100644
index 8e02ce17de..0000000000
--- a/bt5/erp5_workflow/SkinTemplateItem/portal_skins/erp5_workflow/ERP5WorkflowTool_viewWorkflowList/workflows.xml
+++ /dev/null
@@ -1,157 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>delegated_list</string> </key>
-            <value>
-              <list>
-                <string>columns</string>
-                <string>editable_columns</string>
-                <string>hide_rows_on_no_search_criterion</string>
-                <string>portal_types</string>
-                <string>selection_name</string>
-                <string>sort</string>
-                <string>title</string>
-              </list>
-            </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>workflows</string> </value>
-        </item>
-        <item>
-            <key> <string>message_values</string> </key>
-            <value>
-              <dictionary>
-                <item>
-                    <key> <string>external_validator_failed</string> </key>
-                    <value> <string>The input failed the external validator.</string> </value>
-                </item>
-              </dictionary>
-            </value>
-        </item>
-        <item>
-            <key> <string>overrides</string> </key>
-            <value>
-              <dictionary>
-                <item>
-                    <key> <string>field_id</string> </key>
-                    <value> <string></string> </value>
-                </item>
-                <item>
-                    <key> <string>form_id</string> </key>
-                    <value> <string></string> </value>
-                </item>
-                <item>
-                    <key> <string>target</string> </key>
-                    <value> <string></string> </value>
-                </item>
-              </dictionary>
-            </value>
-        </item>
-        <item>
-            <key> <string>tales</string> </key>
-            <value>
-              <dictionary>
-                <item>
-                    <key> <string>field_id</string> </key>
-                    <value> <string></string> </value>
-                </item>
-                <item>
-                    <key> <string>form_id</string> </key>
-                    <value> <string></string> </value>
-                </item>
-                <item>
-                    <key> <string>target</string> </key>
-                    <value> <string></string> </value>
-                </item>
-              </dictionary>
-            </value>
-        </item>
-        <item>
-            <key> <string>values</string> </key>
-            <value>
-              <dictionary>
-                <item>
-                    <key> <string>columns</string> </key>
-                    <value>
-                      <list>
-                        <tuple>
-                          <string>reference</string>
-                          <string>Reference</string>
-                        </tuple>
-                        <tuple>
-                          <string>title</string>
-                          <string>Title</string>
-                        </tuple>
-                        <tuple>
-                          <string>description</string>
-                          <string>Description</string>
-                        </tuple>
-                      </list>
-                    </value>
-                </item>
-                <item>
-                    <key> <string>editable_columns</string> </key>
-                    <value>
-                      <list/>
-                    </value>
-                </item>
-                <item>
-                    <key> <string>field_id</string> </key>
-                    <value> <string>my_list_mode_listbox</string> </value>
-                </item>
-                <item>
-                    <key> <string>form_id</string> </key>
-                    <value> <string>Base_viewFieldLibrary</string> </value>
-                </item>
-                <item>
-                    <key> <string>hide_rows_on_no_search_criterion</string> </key>
-                    <value> <int>0</int> </value>
-                </item>
-                <item>
-                    <key> <string>portal_types</string> </key>
-                    <value>
-                      <list>
-                        <tuple>
-                          <string>Workflow</string>
-                          <string>Workflow</string>
-                        </tuple>
-                      </list>
-                    </value>
-                </item>
-                <item>
-                    <key> <string>selection_name</string> </key>
-                    <value> <string>portal_workflow_selection</string> </value>
-                </item>
-                <item>
-                    <key> <string>sort</string> </key>
-                    <value>
-                      <list>
-                        <tuple>
-                          <string>reference</string>
-                          <string>Reference</string>
-                        </tuple>
-                      </list>
-                    </value>
-                </item>
-                <item>
-                    <key> <string>target</string> </key>
-                    <value> <string>Click to edit the target</string> </value>
-                </item>
-                <item>
-                    <key> <string>title</string> </key>
-                    <value> <string>Workflows</string> </value>
-                </item>
-              </dictionary>
-            </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/product/ERP5/ERP5Site.py b/product/ERP5/ERP5Site.py
index 9b6a2b19df..d1591a3ccc 100644
--- a/product/ERP5/ERP5Site.py
+++ b/product/ERP5/ERP5Site.py
@@ -763,7 +763,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
         if wf.__class__.__name__ == 'Workflow':
           for state in wf.objectValues(portal_type='State'):
             if group in getattr(state, 'type_list', ()):
-              state_dict['_'.join(state.getId().split('_')[:-1])] = None
+              state_dict['_'.join(state.getId().split('_')[1:])] = None
         else:
           if getattr(wf, 'states', None):
             for state in wf.states.objectValues():
@@ -1294,7 +1294,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
             if wf.objectValues(portal_type='State'):
               for state in wf.objectValues(portal_type='State'):
                 if getattr(state, 'type_list', None):
-                  state_dict['_'.join(state.getId().split('_')[:-1])] = None
+                  state_dict['_'.join(state.getId().split('_')[1:])] = None
         else:
           if getattr(wf, 'variables', None) and \
              wf.variables.getStateVar() == 'simulation_state':
@@ -1719,7 +1719,7 @@ class PortalGenerator:
         addCMFCoreTool('CMF Skins Tool', None)
         addCMFCoreTool('CMF Undo Tool', None)
         addCMFCoreTool('CMF URL Tool', None)
-        addCMFCoreTool('CMF Workflow Tool', None)
+        #addCMFCoreTool('CMF Workflow Tool', None) # taken place by ERP5 Workflow Tool
 
         addCMFDefaultTool = p.manage_addProduct['CMFDefault'].manage_addTool
         addCMFDefaultTool('Default Discussion Tool', None)
@@ -1925,6 +1925,7 @@ class ERP5Generator(PortalGenerator):
     addERP5Tool(p, 'portal_password', 'Password Tool')
     addERP5Tool(p, 'portal_introspections', 'Introspection Tool')
     addERP5Tool(p, 'portal_acknowledgements', 'Acknowledgement Tool')
+    addERP5Tool(p, 'portal_workflow', 'ERP5 Workflow Tool')
 
     # Add ERP5Type Tool
     addERP5Tool(p, 'portal_caches', 'Cache Tool')
-- 
2.30.9