From 7a4831d9c466648f8920a2e90b589a21ecd39711 Mon Sep 17 00:00:00 2001
From: Wenjie Zheng <wenjie.zheng@tiolive.com>
Date: Mon, 4 May 2015 16:34:29 +0000
Subject: [PATCH] ERP5Site.py: deploy unique methods for both erp5 workflow and
 DC workflow.

---
 product/ERP5/ERP5Site.py | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/product/ERP5/ERP5Site.py b/product/ERP5/ERP5Site.py
index c764db148b..cac60f1539 100644
--- a/product/ERP5/ERP5Site.py
+++ b/product/ERP5/ERP5Site.py
@@ -760,16 +760,9 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
     def getStateList(group):
       state_dict = {}
       for wf in self.portal_workflow.objectValues():
-        if getattr(wf, 'states', None):
-          # DC Workflow
-          for state in wf.states.objectValues():
-            if group in getattr(state, 'type_list', ()):
-              state_dict[state.getId()] = None
-        else:
-          # ERP5 Workflow
-          for state in wf.objectValues(portal_type='State'):
-            if group in getattr(state, 'type_list', ()):
-              state_dict[state.getReference()] = None
+        for state in wf.getStateList():
+          if group in getattr(state, 'type_list', ()):
+            state_dict[state.getReference()] = None
       return tuple(state_dict.keys())
 
     getStateList = CachingMethod(getStateList,
@@ -1289,20 +1282,10 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
     def getStateList():
       state_dict = {}
       for wf in self.portal_workflow.objectValues():
-        if getattr(wf, 'variables', None) and \
-           wf.variables.getStateVar() == 'simulation_state':
-          # DC Workflow
-          if getattr(wf, 'states', None):
-            for state in wf.states.objectValues():
-              if getattr(state, 'type_list', None):
-                state_dict[state.getId()] = None
-        elif wf.objectValues(portal_type='Variable') and \
-            wf.getStateVariable() == 'simulation_state':
-          # ERP5 Workflow
-          if wf.objectValues(portal_type='State'):
-            for state in wf.objectValues(portal_type='State'):
-              if getattr(state, 'type_list', None):
-                state_dict[state.getReference()] = None
+        if wf.getVariableList() and wf.getStateVariable() == 'simulation_state':
+          for state in wf.getStateList():
+            if getattr(state, 'type_list', None):
+              state_dict[state.getReference()] = None
       return tuple(sorted(state_dict.keys()))
 
     getStateList = CachingMethod(getStateList,
-- 
2.30.9