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

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Aug 31 13:49:02 CEST 2006


Author: jerome
Date: Thu Aug 31 13:48:58 2006
New Revision: 9582

URL: http://svn.erp5.org?rev=9582&view=rev
Log:
fix 'Guess Properties of portal types', it wasn't guessing workflow chain unless a workflow chain was already included.


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=9582&r1=9581&r2=9582&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py Thu Aug 31 13:48:58 2006
@@ -4642,6 +4642,8 @@
       """
       Fill field about properties for each portal type
       """
+      wtool = self.getPortalObject().portal_workflow
+      ttool = self.getPortalObject().portal_types
       bt_allowed_content_type_list = list(getattr(self, 'template_portal_type_allowed_content_type', []) or [])
       bt_hidden_content_type_list = list(getattr(self, 'template_portal_type_hidden_content_type', []) or [])
       bt_property_sheet_list = list(getattr(self, 'template_portal_type_property_sheet', []) or [])
@@ -4651,17 +4653,10 @@
       bt_portal_type_roles_list =  list(getattr(self, 'template_portal_type_roles', []) or [])
       bt_wf_chain_list = list(getattr(self, 'template_portal_type_workflow_chain', []) or [])
 
-      pt_wf_item = getattr(self, '_portal_type_workflow_chain_item', None)
-      if pt_wf_item is not None:
-        chain_dict = getChainByType(self.getPortalObject())[1]
-      else:
-        chain_dict = {}
-
       p = self.getPortalObject()
       for id in bt_portal_types_id_list:
-        try:
-          portal_type = p.unrestrictedTraverse('portal_types/'+id)
-        except KeyError:
+        portal_type = ttool.getTypeInfo(id)
+        if portal_type is None:
           continue
         if len(getattr(portal_type, '_roles', ())) > 0:
           if id not in bt_portal_type_roles_list:
@@ -4672,7 +4667,6 @@
         property_sheet_list = []
         base_category_list = []
         action_list = []
-        wf_list = []
         if hasattr(portal_type, 'allowed_content_types'):
           allowed_content_type_list = portal_type.allowed_content_types
         if hasattr(portal_type, 'hidden_content_type_list'):
@@ -4683,10 +4677,6 @@
           base_category_list = portal_type.base_category_list
         if hasattr(portal_type, 'listActions'):
           action_list = [x.getId() for x in portal_type.listActions()]
-        if chain_dict.has_key('chain_%s' % id):
-          chain = chain_dict['chain_%s' % id]
-          if chain != '' and chain != '(Default)':
-            wf_list = chain.split(', ')
 
         for a_id in allowed_content_type_list:
           allowed_id = id+' | '+a_id
@@ -4713,7 +4703,8 @@
           if action_id not in bt_action_list:
             bt_action_list.append(action_id)
 
-        for workflow_id in wf_list:
+        for workflow_id in [chain in wtool.getChainFor(id)
+                                    if chain != '(Default)']:
           wf_id = id+' | '+workflow_id
           if wf_id not in bt_wf_chain_list:
             bt_wf_chain_list.append(wf_id)
@@ -4725,13 +4716,13 @@
       bt_action_list.sort()
       bt_wf_chain_list.sort()
 
-      setattr(self, 'template_portal_type_workflow_chain', bt_wf_chain_list)
-      setattr(self, 'template_portal_type_roles', bt_portal_type_roles_list)
-      setattr(self, 'template_portal_type_allowed_content_type', bt_allowed_content_type_list)
-      setattr(self, 'template_portal_type_hidden_content_type', bt_hidden_content_type_list)
-      setattr(self, 'template_portal_type_property_sheet', bt_property_sheet_list)
-      setattr(self, 'template_portal_type_base_category', bt_base_category_list)
-      setattr(self, 'template_action_path', bt_action_list)
+      self.setProperty('template_portal_type_workflow_chain', bt_wf_chain_list)
+      self.setProperty('template_portal_type_roles', bt_portal_type_roles_list)
+      self.setProperty('template_portal_type_allowed_content_type', bt_allowed_content_type_list)
+      self.setProperty('template_portal_type_hidden_content_type', bt_hidden_content_type_list)
+      self.setProperty('template_portal_type_property_sheet', bt_property_sheet_list)
+      self.setProperty('template_portal_type_base_category', bt_base_category_list)
+      self.setProperty('template_action_path', bt_action_list)
       return
 
 




More information about the Erp5-report mailing list