[Erp5-report] r27612 - /erp5/trunk/products/ERP5/Document/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Jun 16 16:22:51 CEST 2009
Author: fabien
Date: Tue Jun 16 16:22:44 2009
New Revision: 27612
URL: http://svn.erp5.org?rev=27612&view=rev
Log:
- fix some spelling problems
- fix comment to not use "we" form as it's explain in the wiki (http://www.erp5.org/GuidelinesForDocumentation?highlight=we)
- add context parameter to findEffectiveSpecialiseValueList to be more consistent with findSpecialiseValueList.
Modified:
erp5/trunk/products/ERP5/Document/TradeCondition.py
erp5/trunk/products/ERP5/Document/TradeModelLine.py
Modified: erp5/trunk/products/ERP5/Document/TradeCondition.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TradeCondition.py?rev=27612&r1=27611&r2=27612&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] Tue Jun 16 16:22:44 2009
@@ -41,7 +41,7 @@
import zope.interface
# XXX TODO : getTradeModelLineComposedList and findSpecialiseValueList should
-# probably move to Transformation (better names sould be used)
+# probably move to Transformation (better names should be used)
# XXX TODO: review naming of new methods
# XXX WARNING: current API naming may change although model should be stable.
@@ -93,9 +93,8 @@
movement_to_add_list = []
for movement in existing_movement_list:
keep_movement = False
- # here we have to check if the movement is a generated one or
- # entered by the user. If it has been entered by user, we have to
- # keep it.
+ # check if the movement is a generated one or entered by the user.
+ # If it has been entered by user, keep it.
resource = movement.getResourceValue()
if resource is not None and \
len(set(normal_use_list).intersection(set(resource\
@@ -172,7 +171,7 @@
# for contained Trade Model Lines
document = context.getExplanationValue()
containting_object_list.append(document)
- containting_object_list.extend(self.findSpecialiseValueList(self))
+ containting_object_list.extend(self.findSpecialiseValueList(context=self))
for specialise in containting_object_list:
for trade_model_line in specialise.contentValues(
@@ -239,21 +238,18 @@
security.declareProtected( Permissions.AccessContentsInformation, 'getCell')
def getCell(self, *kw , **kwd):
- '''
- Overload the function getCell to be able to search a cell on the
+ '''Overload the function getCell to be able to search a cell on the
inheritance model tree if the cell is not found on current one.
'''
cell = XMLMatrix.getCell(self, *kw, **kwd)
- # if cell not found, look on the inherited models
if cell is None:
- if kwd.has_key('paysheet'):
- model_list = self.findEffectiveSpecialiseValueList(\
- start_date=kwd['paysheet'].getStartDate(),
- stop_date=kwd['paysheet'].getStopDate())
- else:
- model_list = self.findSpecialiseValueList(context=self)
- if self in model_list:
- model_list.remove(self)
+ # if cell not found, look on the inherited models
+ start_date = kwd.has_key('paysheet') and \
+ kwd['paysheet'].getStartDate() or None
+ stop_date = kwd.has_key('paysheet') and \
+ kwd['paysheet'].getStopDate() or None
+ model_list = self.findEffectiveSpecialiseValueList(\
+ context=self, start_date=start_date, stop_date=stop_date)
for specialised_model in model_list:
cell = XMLMatrix.getCell(specialised_model, *kw, **kwd)
if cell is not None:
@@ -264,7 +260,7 @@
'getReferenceDict')
def getReferenceDict(self, portal_type_list, property_list=None):
'''Return a dict containing all id's of the objects contained in
- this model and correponding to the given portal_type. The key of the dict
+ this model and corresponding to the given portal_type. The key of the dict
are the reference (or id if no reference)
'''
if property_list is None:
@@ -284,13 +280,16 @@
security.declareProtected(Permissions.AccessContentsInformation,
'findEffectiveSpecialiseValueList')
- def findEffectiveSpecialiseValueList(self, start_date=None, stop_date=None):
+ def findEffectiveSpecialiseValueList(self, context, start_date=None,
+ stop_date=None):
'''Returns a list of effective specialised objects representing
inheritance tree.
- An effective object is an object wich start and stop_date are equal (or
+ An effective object is an object which start and stop_date are equal (or
included) to the range of the given start and stop_date.
- '''
- model_list = self.findSpecialiseValueList(self)
+ 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\
@@ -328,7 +327,7 @@
def getEffectiveModel(self, start_date=None, stop_date=None):
'''return the more appropriate model using effective_date, expiration_date
and version number
- An effective model is a model wich start and stop_date are equal (or
+ 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
higher version number (if there is more than one)
'''
@@ -353,7 +352,7 @@
if len(effective_model_list):
return effective_model_list[0]
- # else, if there is model wich has effective period containing
+ # else, 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 \
@@ -373,6 +372,7 @@
if v:
return v
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)
Modified: erp5/trunk/products/ERP5/Document/TradeModelLine.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TradeModelLine.py?rev=27612&r1=27611&r2=27612&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TradeModelLine.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TradeModelLine.py [utf8] Tue Jun 16 16:22:44 2009
@@ -51,7 +51,7 @@
TODO:
- make this code readable
- use comments
- - use docstrings
+ - use doctrings
"""
meta_type = 'ERP5 Trade Model Line'
portal_type = 'Trade Model Line'
@@ -135,8 +135,8 @@
tmp_movement_list = [q for q in current_aggregated_amount_list \
if q.getReference() == self.getReference() ]
if len(tmp_movement_list) > 0:
- tmp_movement_list = tmp_movement_list[:1] # we need a list in case we
- # have cells
+ tmp_movement_list = tmp_movement_list[:1] # list is needed in case of
+ # having cells
update = 1
else:
common_params = {
@@ -158,7 +158,7 @@
base_category_list=base_cat)
category_list_list.append(category_list)
cartesian_product = cartesianProduct(category_list_list)
- # if categories are used, we want to look for all cells
+ # look for cells if categories are used
if len(category_list_list) > 0:
for cell_coordinates in cartesian_product:
cell = self.getCell(base_id=base_id, *cell_coordinates)
@@ -188,9 +188,8 @@
self.getQuantity(None) is None or \
len(self.getVariationCategoryList()) and \
tmp_movement.getQuantity(None) is None:
- # if the quantity is not defined, that mean we should search on
- # all movements with corresponding base_amount (if we use cells, we
- # have to look on cells, if we don't, look on self)
+ # if the quantity is not defined, take it by searching all movements
+ # that used this base_amount
for movement in movement_list:
if set(base_application_list)\
.intersection(set(movement.getBaseContributionList())) and \
@@ -204,7 +203,7 @@
modified = 1
tmp_movement.setQuantity(quantity + movement.getTotalPrice())
else:
- # if the quantity is defined, we use it
+ # if the quantity is defined, use it
modified = 1
if tmp_movement.getPrice() in (0, None):
# if price is not defined, it the same as 100 %
@@ -215,7 +214,7 @@
base_category_list='salary_range') #XXX hardcoded values
salary_range = len(salary_range_list) and salary_range_list[0] or None
if salary_range is not None:
- # we use slice
+ # slice are used
model = self.getParentValue()
cell = model.getCell(salary_range)
if cell is None:
More information about the Erp5-report
mailing list