[Erp5-report] r15602 - /erp5/trunk/products/ERP5/Document/Inventory.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Aug 10 15:51:49 CEST 2007


Author: vincent
Date: Fri Aug 10 15:51:49 2007
New Revision: 15602

URL: http://svn.erp5.org?rev=15602&view=rev
Log:
Use a dict instead of a list for already-found (resource, variation_text) combinations.
Factorise (resource, variation_text) key generation.
Move getPortalCurrentInventoryStateList call out of loop.
Mae dict "instanciate dict & set key" a single instantiation containing edited key.

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

Modified: erp5/trunk/products/ERP5/Document/Inventory.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Inventory.py?rev=15602&r1=15601&r2=15602&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Inventory.py (original)
+++ erp5/trunk/products/ERP5/Document/Inventory.py Fri Aug 10 15:51:49 2007
@@ -77,29 +77,31 @@
       to have our own temp object constructor, this is usefull if we
       want to use some classes with some particular methods
       """
-      resource_and_variation_list = []
+      resource_and_variation_dict = {}
       stock_object_list = []
       if temp_constructor is None:
         from Products.ERP5Type.Document import newTempDeliveryLine
         temp_constructor = newTempDeliveryLine
       start_date = self.getStartDate()
       node = self.getDestination()
+      current_inventory_state_list = self.getPortalCurrentInventoryStateList()
       for movement in self.getMovementList():
         resource =  movement.getResourceValue()
         if resource is not None and movement.getQuantity() not in (None,''):
           variation_text = movement.getVariationText()
-          if (resource,variation_text) not in resource_and_variation_list:
-            resource_and_variation_list.append((resource,variation_text))
+          resource_and_variation_key = (resource,variation_text)
+          if resource_and_variation_key not in resource_and_variation_dict:
+            resource_and_variation_dict[resource_and_variation_key] = None
             current_inventory_list = resource.getInventoryList( \
                                     to_date          = start_date
                                   , variation_text   = variation_text
                                   , node             = node
-                                  , simulation_state = self.getPortalCurrentInventoryStateList()
+                                  , simulation_state = current_inventory_state_list
                                   , group_by_sub_variation = 1
                                   , group_by_variation = 1
                                   )
-            kwd = {'uid':self.getUid()}
-            kwd['start_date'] = start_date
+            kwd = {'uid':self.getUid(),
+                   'start_date': start_date}
             variation_list = variation_text.split('\n')
             for inventory in current_inventory_list:
               sub_variation_list = []




More information about the Erp5-report mailing list