[Erp5-report] r27653 - /erp5/trunk/products/ERP5/Document/TradeCondition.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jun 18 14:45:27 CEST 2009


Author: fabien
Date: Thu Jun 18 14:45:20 2009
New Revision: 27653

URL: http://svn.erp5.org?rev=27653&view=rev
Log:
- fix a mistake : we don't care about context portal_type but we are interested in self one
- make findEffectiveSpecialiseValueList recursive and change the behaviour :
     now, we check the first model from the inheritance tree, if this model is effective, use it, else take the effective one.
     On this effective model, get all specialise_value and take their effective value.
     Return the list of all this new effective inheritance tree

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

Modified: erp5/trunk/products/ERP5/Document/TradeCondition.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TradeCondition.py?rev=27653&r1=27652&r2=27653&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] Thu Jun 18 14:45:20 2009
@@ -127,7 +127,7 @@
          Uses Breadth First Search.
       """
       if portal_type_list is None:
-        portal_type_list = [context.getPortalType()]
+        portal_type_list = [self.getPortalType()]
       if context.getPortalType() in portal_type_list:
         specialise_value_list = [context]
         visited_trade_condition_list = [context]
@@ -282,7 +282,7 @@
     security.declareProtected(Permissions.AccessContentsInformation,
         'findEffectiveSpecialiseValueList')
     def findEffectiveSpecialiseValueList(self, context, start_date=None,
-        stop_date=None):
+        stop_date=None, portal_type_list=None, effecive_model_list=None):
       '''Returns a list of effective specialised objects representing
       inheritance tree.
       An effective object is an object which start and stop_date are equal (or
@@ -290,12 +290,24 @@
       If no start date and stop date are provided, findSpecialiseValueList is
       returned
       '''
-      model_list = self.findSpecialiseValueList(context=context)
       if start_date is None and stop_date is None:
-        return model_list
-      new_list = [model.getEffectiveModel(start_date, stop_date) for model in\
-          model_list]
-      return new_list
+        # if dates are not defined, return the specalise_value_list
+        return self.findSpecialiseValueList(context=context)
+      if effecive_model_list is None:
+        effecive_model_list=[]
+      if portal_type_list is None:
+        portal_type_list = [self.getPortalType()]
+
+      new_model = self.getEffectiveModel(start_date, stop_date)
+      model_list = new_model.getSpecialiseValueList(portal_type=\
+          portal_type_list)
+      effecive_model_list.append(new_model)
+      for model in model_list:
+        model.findEffectiveSpecialiseValueList(context=context,
+            start_date=start_date, stop_date=stop_date,
+            portal_type_list=portal_type_list,
+            effecive_model_list=effecive_model_list)
+      return effecive_model_list
 
     security.declareProtected(Permissions.AccessContentsInformation,
         'getInheritanceReferenceDict')




More information about the Erp5-report mailing list