Commit f3f6031a authored by Fabien Morin's avatar Fabien Morin

use only the catalog for better performance

limit result to 1 because they are sorted by version and date, so if there is some results, the first one is the best.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27795 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 17a597b9
...@@ -358,17 +358,15 @@ class TradeCondition(Path, Transformation, XMLMatrix): ...@@ -358,17 +358,15 @@ class TradeCondition(Path, Transformation, XMLMatrix):
model_object_list = [result.getObject() for result in \ model_object_list = [result.getObject() for result in \
self.portal_catalog(portal_type=self.portal_type, self.portal_catalog(portal_type=self.portal_type,
reference=reference, reference=reference,
sort_on=(('version','descending'),))] sort_on=(('version','descending'),),
effective_date="<=%s"%start_date,
# if there is model which has effective period containing expiration_date=">=%s"%stop_date,
# the start_date and the stop date of the paysheet, return it limit=1)]
for current_model in model_object_list: if len(model_object_list):
if current_model.getEffectiveDate() <= start_date and \ return model_object_list[0].getObject()
current_model.getExpirationDate() >= stop_date: else:
effective_model_list.append(current_model) # if no effective model are found (ex. because dates are None),
if len(effective_model_list): # return self
return effective_model_list[0]
# if no effective model are found (ex. because dates are None), return self
return self return self
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
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