From 72abe0a256e24c53bf6b46a6fc8ae31d4d930716 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Sun, 19 Feb 2006 19:06:11 +0000
Subject: [PATCH] Use alternateReindexObject to specify a different behavior
 for indexing.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5749 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Inventory.py | 42 +++++-------------------------
 1 file changed, 6 insertions(+), 36 deletions(-)

diff --git a/product/ERP5/Document/Inventory.py b/product/ERP5/Document/Inventory.py
index 80f79c8a4b..a75488b57a 100755
--- a/product/ERP5/Document/Inventory.py
+++ b/product/ERP5/Document/Inventory.py
@@ -67,6 +67,11 @@ class Inventory(Delivery):
       """
       return 'delivered' # For now, consider that Inventory has no workflow XXX
 
+    security.declarePublic('alternateReindexObject')
+    def alternateReindexObject(self, **kw):
+      """This method is called when an inventory object is included in a group of catalogged objects.
+      """
+      return self.immediateReindexObject(**kw)
 
     def immediateReindexObject(self,**kw):
       """
@@ -118,42 +123,7 @@ class Inventory(Delivery):
         from Products.ERP5Type.Document import newTempBase
         stock_object_list.append(newTempDeliveryLine(self,self.getId(),
                                  uid=self.getUid()))
-      LOG('stock_object_list',0,[x.__dict__ for x in stock_object_list])
+      #LOG('stock_object_list',0,[x.__dict__ for x in stock_object_list])
       self.portal_catalog.catalogObjectList(stock_object_list,
            method_id_list=('z_catalog_stock_list',),
            disable_cache=1,check_uid=0)
-
-    security.declarePublic( 'recursiveReindexObject' )
-    def recursiveReindexObject(self, *args, **kw):
-      """
-      Do not use group_method_id for the inventory, but it can
-      be used for inventory lines and cells
-      """
-      root_indexable = int(getattr(self.getPortalObject(),'isIndexable',1))
-      self._reindexObject()
-      if self.isIndexable and root_indexable:
-        self.activate(group_method_id='portal_catalog/catalogObjectList', 
-            expand_method_id='getIndexableChildValueList', 
-            **kw).recursiveImmediateReindexObject(*args, **kw)
-
-    security.declareProtected( Permissions.AccessContentsInformation, 'getIndexableChildValueList' )
-    def getIndexableChildValueList(self):
-      """
-        Get indexable childen recursively.
-      """
-      value_list = []
-      if self.isIndexable:
-        #value_list.append(self) # do not include self
-        for c in self.objectValues():
-          if hasattr(aq_base(c), 'getIndexableChildValueList'):
-            value_list.extend(c.getIndexableChildValueList())
-      return value_list
-
-    def _reindexObject(self, *args, **kw):
-      """
-      Defined here because we want to 
-      Make sure to call without the group_method_id for inventories
-      """
-      root_indexable = int(getattr(self.getPortalObject(),'isIndexable',1))
-      if self.isIndexable and root_indexable:
-        self.activate(**kw).immediateReindexObject(*args, **kw)
-- 
2.30.9