[Erp5-report] r45130 luke - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Apr 6 13:52:05 CEST 2011


Author: luke
Date: Wed Apr  6 13:52:05 2011
New Revision: 45130

URL: http://svn.erp5.org?rev=45130&view=rev
Log:
 - remove workflow chains which were removed from Business Template

When BT A defined that portal type X shall be chained with workflows
1 and 2, but later same Business Template defines that workflow 2
shall not be chained the workflow chain shall be updated.

Modified:
    erp5/trunk/products/ERP5/Document/BusinessTemplate.py

Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=45130&r1=45129&r2=45130&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Wed Apr  6 13:52:05 2011
@@ -2019,6 +2019,12 @@ class PortalTypeWorkflowChainTemplateIte
   def install(self, context, trashbin, **kw):
     update_dict = kw.get('object_to_update')
     force = kw.get('force')
+    installed_bt = kw.get('installed_bt')
+    if installed_bt is not None:
+      previous_portal_type_workflow_chain_list = list(installed_bt\
+          .getTemplatePortalTypeWorkflowChainList())
+    else:
+      previous_portal_type_workflow_chain_list = []
     # We now need to setup the list of workflows corresponding to
     # each portal type
     (default_chain, chain_dict) = getChainByType(context)
@@ -2049,6 +2055,26 @@ class PortalTypeWorkflowChainTemplateIte
           old_chain_workflow_id_set = set(old_chain_list)
           # get new workflow id list
           workflow_id_list = self._objects[path]
+          # fetch list of new workflows which shall be added to chains
+          addative_workflow_id_list = [q.lstrip('+') for q in workflow_id_list\
+              if not q.startswith('-') and not q.startswith('=')]
+          for previous_line in [q for q in \
+              previous_portal_type_workflow_chain_list \
+              if q.startswith(portal_type)]:
+            previous_portal_type, previous_workflow_id = previous_line.split(
+                '|')
+            previous_portal_type = previous_portal_type.strip()
+            previous_workflow_id = previous_workflow_id.strip()
+            if not previous_workflow_id.startswith('-') \
+                and not previous_workflow_id.startswith('='):
+              # else: nothing can be done if previously workflow was removed
+              # or replaced as this requires introspection on global system
+              previous_workflow_id = previous_workflow_id.lstrip('+')
+              if previous_workflow_id not in addative_workflow_id_list:
+                # In previous Business Template workflow was chained with
+                # portal type, but current Business Template cancels this
+                # so it shall be removed
+                workflow_id_list.append('-%s' % previous_workflow_id)
           for wf_id in workflow_id_list:
             if wf_id[0] == '-':
               # remove wf id if already present



More information about the Erp5-report mailing list