Commit db0a0e4a authored by Fabien Morin's avatar Fabien Morin

- 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


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27653 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c8002284
...@@ -127,7 +127,7 @@ class TradeCondition(Path, Transformation, XMLMatrix): ...@@ -127,7 +127,7 @@ class TradeCondition(Path, Transformation, XMLMatrix):
Uses Breadth First Search. Uses Breadth First Search.
""" """
if portal_type_list is None: if portal_type_list is None:
portal_type_list = [context.getPortalType()] portal_type_list = [self.getPortalType()]
if context.getPortalType() in portal_type_list: if context.getPortalType() in portal_type_list:
specialise_value_list = [context] specialise_value_list = [context]
visited_trade_condition_list = [context] visited_trade_condition_list = [context]
...@@ -282,7 +282,7 @@ class TradeCondition(Path, Transformation, XMLMatrix): ...@@ -282,7 +282,7 @@ class TradeCondition(Path, Transformation, XMLMatrix):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'findEffectiveSpecialiseValueList') 'findEffectiveSpecialiseValueList')
def findEffectiveSpecialiseValueList(self, context, start_date=None, 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 '''Returns a list of effective specialised objects representing
inheritance tree. inheritance tree.
An effective object is an object which start and stop_date are equal (or An effective object is an object which start and stop_date are equal (or
...@@ -290,12 +290,24 @@ class TradeCondition(Path, Transformation, XMLMatrix): ...@@ -290,12 +290,24 @@ class TradeCondition(Path, Transformation, XMLMatrix):
If no start date and stop date are provided, findSpecialiseValueList is If no start date and stop date are provided, findSpecialiseValueList is
returned returned
''' '''
model_list = self.findSpecialiseValueList(context=context)
if start_date is None and stop_date is None: if start_date is None and stop_date is None:
return model_list # if dates are not defined, return the specalise_value_list
new_list = [model.getEffectiveModel(start_date, stop_date) for model in\ return self.findSpecialiseValueList(context=context)
model_list] if effecive_model_list is None:
return new_list 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, security.declareProtected(Permissions.AccessContentsInformation,
'getInheritanceReferenceDict') 'getInheritanceReferenceDict')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment