[Erp5-report] r41788 nicolas.dumazet - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Dec 27 10:21:11 CET 2010


Author: nicolas.dumazet
Date: Mon Dec 27 10:21:11 2010
New Revision: 41788

URL: http://svn.erp5.org?rev=41788&view=rev
Log:
When creating a business template with ZODB property sheets, if the ids
refer to property sheets existing in portal_property_sheets, change the path
on the fly to refer to the object in the portal.


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=41788&r1=41787&r2=41788&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Mon Dec 27 10:21:11 2010
@@ -3468,7 +3468,20 @@ class PropertySheetTemplateItem(Document
   local_file_importer_name = staticmethod(importLocalPropertySheet)
   local_file_remover_name = staticmethod(removeLocalPropertySheet)
 
-  def __init__(self, id_list, tool_id='portal_property_sheets', **kw):
+  def __init__(self, id_list, tool_id='portal_property_sheets', context=None, **kw):
+    tool = None
+    if context is not None and len(id_list):
+      # XXX looking up a tool early in the install process might
+      # cause issues. If it does, we'll have to consider moving this
+      # to build()
+      tool = getattr(context.getPortalObject(), tool_id, None)
+    if tool is not None:
+      existing_property_sheet_set = set(tool.objectIds())
+      for i, id in enumerate(id_list):
+        if id in existing_property_sheet_set:
+          # if the property sheet is on ZODB, use it.
+          id_list[i] = "%s/%s" % (tool_id, id)
+
     BaseTemplateItem.__init__(self, id_list, **kw)
 
   @staticmethod
@@ -4447,7 +4460,8 @@ Business Template is a set of definition
       self._document_item = \
           DocumentTemplateItem(self.getTemplateDocumentIdList())
       self._property_sheet_item = \
-          PropertySheetTemplateItem(self.getTemplatePropertySheetIdList())
+          PropertySheetTemplateItem(self.getTemplatePropertySheetIdList(),
+                                    context=self)
       self._constraint_item = \
           ConstraintTemplateItem(self.getTemplateConstraintIdList())
       self._extension_item = \



More information about the Erp5-report mailing list