[Erp5-report] r7570 - in /erp5/trunk/products/ERP5: Document/ Extensions/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jun 1 13:50:33 CEST 2006


Author: jerome
Date: Thu Jun  1 13:50:27 2006
New Revision: 7570

URL: http://svn.erp5.org?rev=7570&view=rev
Log:
Fixed the fact that IventoryBrain.getExplanationText cannot find the
explanation for "Virtual" Inventory movements. 


Modified:
    erp5/trunk/products/ERP5/Document/Inventory.py
    erp5/trunk/products/ERP5/Extensions/InventoryBrain.py
    erp5/trunk/products/ERP5/tests/testInventoryModule.py

Modified: erp5/trunk/products/ERP5/Document/Inventory.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Inventory.py?rev=7570&r1=7569&r2=7570&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Inventory.py (original)
+++ erp5/trunk/products/ERP5/Document/Inventory.py Thu Jun  1 13:50:27 2006
@@ -62,7 +62,8 @@
 
     security.declarePublic('alternateReindexObject')
     def alternateReindexObject(self, **kw):
-      """This method is called when an inventory object is included in a group of catalogged objects.
+      """This method is called when an inventory object is included in a
+      group of catalogged objects.
       """
       return self.immediateReindexObject(**kw)
 

Modified: erp5/trunk/products/ERP5/Extensions/InventoryBrain.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Extensions/InventoryBrain.py?rev=7570&r1=7569&r2=7570&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Extensions/InventoryBrain.py (original)
+++ erp5/trunk/products/ERP5/Extensions/InventoryBrain.py Thu Jun  1 13:50:27 2006
@@ -162,10 +162,15 @@
   def getListItemUrl(self, cname_id, selection_index, selection_name):
     # XXX FIXME can catch to many exceptions
     try:
-      if cname_id in ('getExplanationText','getExplanation', ):
+      if cname_id in ('getExplanationText', 'getExplanation', ):
         o = self.getObject()
         if o is not None:
-          explanation = o.getExplanationValue()
+          if not getattr(o, 'isDelivery', 0):
+            explanation = o.getExplanationValue()
+          else:
+            # Additional inventory movements are catalogged in stock table
+            # with the inventory's uid. Then they are their own explanation.
+            explanation = o
           if explanation is not None:
             return '%s/%s/view' % (
                     self.portal_url.getPortalObject().absolute_url(),
@@ -238,7 +243,12 @@
     if o is not None:
       N_ = lambda msg, **kw: o.Localizer.translate('ui', msg, **kw)
       # Get the delivery/order
-      delivery = o.getExplanationValue()
+      if not getattr(o, 'isDelivery', 0):
+        delivery = o.getExplanationValue()
+      else:
+        # Additional inventory movements are catalogged in stock table
+        # with the inventory's uid. Then they are their own explanation.
+        delivery = o
       if delivery is not None:
         mapping = {
           'delivery_portal_type' : delivery.getTranslatedPortalType(),

Modified: erp5/trunk/products/ERP5/tests/testInventoryModule.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testInventoryModule.py?rev=7570&r1=7569&r2=7570&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testInventoryModule.py (original)
+++ erp5/trunk/products/ERP5/tests/testInventoryModule.py Thu Jun  1 13:50:27 2006
@@ -42,17 +42,9 @@
 
 from Testing import ZopeTestCase
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
-from AccessControl.SecurityManagement import newSecurityManager, \
-                                             noSecurityManager
 from DateTime import DateTime
-from Acquisition import aq_base, aq_inner
 from zLOG import LOG
-from Products.ERP5Type.DateUtils import addToDate
 from Products.ERP5Type.tests.Sequence import Sequence, SequenceList
-import time
-import os
-from Products.ERP5Type import product_path
-from Products.CMFCore.utils import getToolByName
 from testOrder import TestOrderMixin
 
 class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
@@ -162,8 +154,8 @@
                         resource_value = resource)
     return inventory
 
-  def stepCreateFirstNotVariatedInventory(self, sequence=None, sequence_list=None, \
-                                 **kw):
+  def stepCreateFirstNotVariatedInventory(self, sequence=None,
+                                          sequence_list=None, **kw):
     """
     We will put default values for an inventory
     """
@@ -175,8 +167,8 @@
     self.createNotVariatedInventoryLine(sequence=sequence,
                                     quantity=quantity)
 
-  def stepCreateSecondNotVariatedInventory(self, sequence=None, sequence_list=None, \
-                                 **kw):
+  def stepCreateSecondNotVariatedInventory(self, sequence=None,
+                                           sequence_list=None, **kw):
     """
     We will put default values for an inventory
     """
@@ -198,11 +190,12 @@
     self.assertEquals(self.default_quantity,quantity)
 
   def stepCheckSecondNotVariatedInventory(self, start_date=None,quantity=None,
-                                             sequence=None,**kw):
-    node_uid = sequence.get('organisation1').getUid()
-    resource_url = sequence.get('resource').getRelativeUrl()
-    date = DateTime(self.view_stock_date)
-    LOG('CheckSecondNotVariatedInventory',0, self.getSimulationTool().getInventory(node_uid=node_uid,
+                                             sequence=None, **kw):
+    node_uid = sequence.get('organisation1').getUid()
+    resource_url = sequence.get('resource').getRelativeUrl()
+    date = DateTime(self.view_stock_date)
+    LOG('CheckSecondNotVariatedInventory', 0,
+        self.getSimulationTool().getInventory(node_uid=node_uid,
                         resource=resource_url,
                         to_date=date,src__=1))
     quantity = self.getSimulationTool().getInventory(node_uid=node_uid,
@@ -223,22 +216,22 @@
     sequence_list = SequenceList()
 
     # Test with a simple inventory without cell
-    sequence_string = 'CreateNotVariatedResource \
-                       CreateOrganisation1 \
-                       CreateInitialMovements \
-                       Tic \
-                       CreateFirstNotVariatedInventory \
-                       Tic \
-                       CheckFirstNotVariatedInventory \
-                       CreateSecondNotVariatedInventory \
-                       Tic \
-                       CheckSecondNotVariatedInventory'
+    sequence_string = 'stepCreateNotVariatedResource \
+                       stepCreateOrganisation1 \
+                       stepCreateInitialMovements \
+                       stepTic \
+                       stepCreateFirstNotVariatedInventory \
+                       stepTic \
+                       stepCheckFirstNotVariatedInventory \
+                       stepCreateSecondNotVariatedInventory \
+                       stepTic \
+                       stepCheckSecondNotVariatedInventory'
     sequence_list.addSequenceString(sequence_string)
 
     sequence_list.play(self)
 
   def createVariatedInventoryLine(self, sequence=None, sequence_list=None, 
-                                 start_date=None,quantity=None,item_list=None,
+                                 start_date=None, quantity=None, item_list=None,
                                  **kw):
     """
     We will put default values for an inventory
@@ -250,7 +243,8 @@
            portal_type=self.inventory_line_portal_type)
     inventory_line.edit(resource_value = resource)
     resource_vcl = list(resource.getVariationCategoryList(
-                                   omit_individual_variation=1,omit_option_base_category=1))
+                                   omit_individual_variation=1,
+                                   omit_option_base_category=1))
     resource_vcl.sort()
     self.assertEquals(len(resource_vcl),2)
     inventory_line.setVariationCategoryList(resource_vcl)
@@ -259,8 +253,9 @@
     cell_key_list.sort()
     price = 100
     for cell_key in cell_key_list:
-      cell = inventory_line.newCell(base_id=base_id, \
-                                portal_type=self.inventory_cell_portal_type, *cell_key)
+      cell = inventory_line.newCell(base_id=base_id,
+                                portal_type=self.inventory_cell_portal_type,
+                                *cell_key)
       cell.edit(mapped_value_property_list=['price','inventory'],
                 price=price, inventory=quantity,
                 predicate_category_list=cell_key,
@@ -299,7 +294,8 @@
     """
     We will put default values for an inventory
     """
-    inventory = self.createNotVariatedInventory(sequence=sequence,start_date=start_date)
+    inventory = self.createNotVariatedInventory(sequence=sequence,
+                                                start_date=start_date)
     resource = sequence.get('resource_list')[0]
     organisation =  sequence.get('organisation1')
     inventory = self.getInventoryModule().newContent()
@@ -357,16 +353,16 @@
     sequence_list = SequenceList()
 
     # Test with a variated inventory
-    sequence_string = 'CreateVariatedResource \
-                       CreateOrganisation1 \
-                       CreateInitialMovements \
-                       Tic \
-                       CreateFirstVariatedInventory \
-                       Tic \
-                       CheckFirstVariatedInventory \
-                       CreateSecondVariatedInventory \
-                       Tic \
-                       CheckSecondVariatedInventory'
+    sequence_string = 'stepCreateVariatedResource \
+                       stepCreateOrganisation1 \
+                       stepCreateInitialMovements \
+                       stepTic \
+                       stepCreateFirstVariatedInventory \
+                       stepTic \
+                       stepCheckFirstVariatedInventory \
+                       stepCreateSecondVariatedInventory \
+                       stepTic \
+                       stepCheckSecondVariatedInventory'
     sequence_list.addSequenceString(sequence_string)
 
     sequence_list.play(self)
@@ -409,8 +405,8 @@
     relative_url_text = '\n'.join(relative_url_list)
     return relative_url_text
 
-  def stepCheckFirstVariatedAggregatedInventory(self, start_date=None,quantity=None,
-                                             sequence=None,**kw):
+  def stepCheckFirstVariatedAggregatedInventory(self, start_date=None,
+                                quantity=None, sequence=None, **kw):
     node_uid = sequence.get('organisation1').getUid()
     resource_url = sequence.get('resource').getRelativeUrl()
     date = DateTime(self.view_stock_date)
@@ -427,7 +423,7 @@
                         to_date=date)
     self.assertEquals(total_quantity,quantity)
     # Also check when we look stock for a particular aggregate
-    sub_variation_text = self.getAggregateRelativeUrlText( 
+    sub_variation_text = self.getAggregateRelativeUrlText(
                                             sequence.get('item_list'))
     total_quantity = 99
     quantity = self.getSimulationTool().getInventory(node_uid=node_uid,
@@ -436,9 +432,28 @@
                         to_date=date,
                         sub_variation_text=sub_variation_text)
     self.assertEquals(total_quantity,quantity)
-
-  def stepCreateSecondVariatedAggregatedInventory(self, sequence=None, sequence_list=None, \
-                                 **kw):
+  
+  def stepCheckExplanationTextInInventoryList(self, start_date=None,
+                                quantity=None, sequence=None, **kw):
+    """Tests getExplanationText from InventoryBrain
+    """
+    # this is rather a test for InventoryBrain
+    node_uid = sequence.get('organisation1').getUid()
+    resource_url = sequence.get('resource').getRelativeUrl()
+    date = DateTime(self.view_stock_date)
+    for inventory_brain in self.getSimulationTool().getInventoryList(
+                        node_uid=node_uid,
+                        resource=resource_url,
+                        to_date=date):
+      self.assertNotEquals(inventory_brain.getExplanationText(),
+                           'Unknown')
+      self.assertNotEquals(inventory_brain.getListItemUrl(
+                                'getExplanationText',
+                                0,
+                                'dummy_selection_name'), '')
+      
+  def stepCreateSecondVariatedAggregatedInventory(self, sequence=None,
+                                      sequence_list=None, **kw):
     """
     We will put default values for an inventory
     - size/Child/32 89    item1,item2
@@ -458,8 +473,8 @@
                   sequence=sequence, quantity=quantity,
                   item_list=item_list)
 
-  def stepCheckSecondVariatedAggregatedInventory(self, start_date=None,quantity=None,
-                                             sequence=None,**kw):
+  def stepCheckSecondVariatedAggregatedInventory(self, start_date=None,
+                                quantity=None, sequence=None, **kw):
     node_uid = sequence.get('organisation1').getUid()
     resource_url = sequence.get('resource').getRelativeUrl()
     date = DateTime(self.view_stock_date)
@@ -476,7 +491,8 @@
                         to_date=date,simulation_state='delivered')
     self.assertEquals(total_quantity,quantity)
     # Also check when we look stock for a particular aggregate
-    sub_variation_text = self.getAggregateRelativeUrlText(sequence.get('item_list'))
+    sub_variation_text = self.getAggregateRelativeUrlText(
+                                                sequence.get('item_list'))
     total_quantity = 0
     quantity = self.getSimulationTool().getInventory(node_uid=node_uid,
                         resource=resource_url,
@@ -484,7 +500,8 @@
                         sub_variation_text=sub_variation_text,
                         simulation_state='delivered')
     self.assertEquals(total_quantity,quantity)
-    sub_variation_text = self.getAggregateRelativeUrlText(sequence.get('item_list')[:1])
+    sub_variation_text = self.getAggregateRelativeUrlText(
+                                    sequence.get('item_list')[:1])
 
   def test_03_VariatedAggregatedInventory(self, run=run_all_test):
     """
@@ -496,19 +513,47 @@
     sequence_list = SequenceList()
 
     # Test with a variated inventory with some aggregate
-    sequence_string = 'CreateVariatedResource \
-                       CreateOrganisation1 \
-                       CreateInitialMovements \
-                       Tic \
-                       CreateItem \
-                       CreateItem \
-                       CreateFirstVariatedAggregatedInventory \
-                       Tic \
-                       CheckFirstVariatedAggregatedInventory \
-                       CreateSecondVariatedAggregatedInventory \
-                       Tic \
-                       CheckSecondVariatedAggregatedInventory'
+    sequence_string = 'stepCreateVariatedResource \
+                       stepCreateOrganisation1 \
+                       stepCreateInitialMovements \
+                       stepTic \
+                       stepCreateItem \
+                       stepCreateItem \
+                       stepCreateFirstVariatedAggregatedInventory \
+                       stepTic \
+                       stepCheckFirstVariatedAggregatedInventory \
+                       stepCreateSecondVariatedAggregatedInventory \
+                       stepTic \
+                       stepCheckSecondVariatedAggregatedInventory'
     sequence_list.addSequenceString(sequence_string)
 
     sequence_list.play(self)
 
+  def test_04_VariatedAggregatedInventoryGetInventoryList(self, run=run_all_test):
+    """
+    Same thing as test_03 with testing getInventoryList columns
+    """
+    if not run: return
+    self.logMessage('Test getInventoryList and Variated Aggregated Inventory')
+
+    sequence_list = SequenceList()
+
+    # Test with a variated inventory with some aggregate
+    sequence_string = 'stepCreateVariatedResource \
+                       stepCreateOrganisation1 \
+                       stepCreateInitialMovements \
+                       stepTic \
+                       stepCreateItem \
+                       stepCreateItem \
+                       stepCreateFirstVariatedAggregatedInventory \
+                       stepTic \
+                       stepCheckFirstVariatedAggregatedInventory \
+                       stepCheckExplanationTextInInventoryList \
+                       stepCreateSecondVariatedAggregatedInventory \
+                       stepTic \
+                       stepCheckSecondVariatedAggregatedInventory \
+                       stepCheckExplanationTextInInventoryList'
+    sequence_list.addSequenceString(sequence_string)
+
+    sequence_list.play(self)
+




More information about the Erp5-report mailing list