[Erp5-report] r27648 - /erp5/trunk/products/ERP5/Document/TradeCondition.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Jun 18 10:25:59 CEST 2009
Author: fabien
Date: Thu Jun 18 10:25:56 2009
New Revision: 27648
URL: http://svn.erp5.org?rev=27648&view=rev
Log:
- use findEffectiveSpecialiseValueList instead of findSpecialiseValueList. This permit to find the more appropriate model to use.
- fix mistake in docstring
- remove useless code parts
- fix the condition of seaching the best maching model (using the dates)
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=27648&r1=27647&r2=27648&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] Thu Jun 18 10:25:56 2009
@@ -171,7 +171,10 @@
# for contained Trade Model Lines
document = context.getExplanationValue()
containting_object_list.append(document)
- containting_object_list.extend(self.findSpecialiseValueList(context=self))
+ start_date = getattr(context, 'start_date', None)
+ stop_date = getattr(context, 'stop_date', None)
+ containting_object_list.extend(self.findEffectiveSpecialiseValueList(context=self,
+ start_date=start_date, stop_date=start_date))
for specialise in containting_object_list:
for trade_model_line in specialise.contentValues(
@@ -325,10 +328,10 @@
security.declareProtected(Permissions.AccessContentsInformation,
'getEffectiveModel')
def getEffectiveModel(self, start_date=None, stop_date=None):
- '''return the more appropriate model using effective_date, expiration_date
- and version number
+ '''Return the more appropriate model using effective_date, expiration_date
+ and version number.
An effective model is a model which start and stop_date are equal (or
- included) to the range of the given start and stop_date and with the
+ excluded) to the range of the given start and stop_date and with the
higher version number (if there is more than one)
'''
reference = self.getReference()
@@ -344,19 +347,11 @@
return cmp(b.getVersion(), a.getVersion())
model_object_list.sort(sortByVersion)
- for current_model in model_object_list:
- # if there is a model with exact dates, return it
- if start_date == current_model.getEffectiveDate() and \
- stop_date == current_model.getExpirationDate():
- effective_model_list.append(current_model)
- if len(effective_model_list):
- return effective_model_list[0]
-
- # else, if there is model which has effective period containing
+ # 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 start_date >= current_model.getEffectiveDate() and \
- stop_date <= current_model.getExpirationDate():
+ 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]
@@ -371,8 +366,7 @@
v = self.getProperty(property_name)
if v:
return v
- model_list = self.findEffectiveSpecialiseValueList(\
- context=self,
+ model_list = self.findEffectiveSpecialiseValueList(context=self,
start_date=paysheet.getStartDate(), stop_date=paysheet.getStopDate())
for specialised_model in model_list:
v = specialised_model.getProperty(property_name)
More information about the Erp5-report
mailing list