[Erp5-report] r27795 - /erp5/trunk/products/ERP5/Document/TradeCondition.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Jun 25 10:57:46 CEST 2009
Author: fabien
Date: Thu Jun 25 10:57:42 2009
New Revision: 27795
URL: http://svn.erp5.org?rev=27795&view=rev
Log:
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.
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=27795&r1=27794&r2=27795&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] Thu Jun 25 10:57:42 2009
@@ -358,18 +358,16 @@
model_object_list = [result.getObject() for result in \
self.portal_catalog(portal_type=self.portal_type,
reference=reference,
- sort_on=(('version','descending'),))]
-
- # if there is model which has effective period containing
- # the start_date and the stop date of the paysheet, return it
- for current_model in model_object_list:
- if current_model.getEffectiveDate() <= start_date and \
- current_model.getExpirationDate() >= stop_date:
- effective_model_list.append(current_model)
- if len(effective_model_list):
- return effective_model_list[0]
- # if no effective model are found (ex. because dates are None), return self
- return self
+ sort_on=(('version','descending'),),
+ effective_date="<=%s"%start_date,
+ expiration_date=">=%s"%stop_date,
+ limit=1)]
+ if len(model_object_list):
+ return model_object_list[0].getObject()
+ else:
+ # if no effective model are found (ex. because dates are None),
+ # return self
+ return self
security.declareProtected(Permissions.AccessContentsInformation,
'getModelIneritanceEffectiveProperty')
More information about the Erp5-report
mailing list