[Erp5-report] r18344 - /erp5/trunk/products/ERP5/Document/
nobody at svn.erp5.org
nobody at svn.erp5.org
Sat Dec 15 20:08:37 CET 2007
Author: fabien
Date: Sat Dec 15 20:08:36 2007
New Revision: 18344
URL: http://svn.erp5.org?rev=18344&view=rev
Log:
- typo
- remove commented code
- modify getInheritanceModelReferenceDict method to use a Breadth First Search
instead of Depth First Search witch is very more appropiate in this case.
Modified:
erp5/trunk/products/ERP5/Document/PaySheetModel.py
erp5/trunk/products/ERP5/Document/PaySheetTransaction.py
Modified: erp5/trunk/products/ERP5/Document/PaySheetModel.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PaySheetModel.py?rev=18344&r1=18343&r2=18344&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PaySheetModel.py (original)
+++ erp5/trunk/products/ERP5/Document/PaySheetModel.py Sat Dec 15 20:08:36 2007
@@ -33,6 +33,8 @@
from Products.ERP5Type.XMLMatrix import XMLMatrix
from zLOG import LOG, WARNING, DEBUG
+#XXX TODO: review naming of new methods
+#XXX WARNING: current API naming may change although model should be stable.
class PaySheetModel(TradeCondition, XMLMatrix):
"""
@@ -95,20 +97,25 @@
return reference_dict
- def getInheritanceModelReferenceDict(self, model_reference_dict,
- model_list, portal_type_list, reference_list):
+ def getInheritanceModelReferenceDict(self, portal_type_list):
'''
return a dict with the model url as key and a list of reference
as value. Normaly, a Reference appear only one time in the final output
+ It's use a Breadth First Search
'''
- # handle the case where just one model is given
- if type(model_list) != type([]):
- model_list = [model_list,]
+ model = self
+ already_add_models = [model]
+ model_list = [model]
+ model_reference_dict = {}
+ reference_list = []
+ id_list = []
- for model in model_list:
+ while len(model_list) != 0:
+ model = model_list.pop(0)
+ id_list = []
+ specialise_list = model.getSpecialiseValueList()
+
model_reference_list=model.getReferenceDict(portal_type_list)
- id_list = []
-
for reference in model_reference_list.keys():
if reference not in reference_list:
reference_list.append(reference)
@@ -117,10 +124,12 @@
if id_list != []:
model_reference_dict[model.getRelativeUrl()]=id_list
- new_model_list = model.getSpecialiseValueList()
- self.getInheritanceModelReferenceDict(\
- model_reference_dict=model_reference_dict,
- model_list=new_model_list,
- portal_type_list=portal_type_list,
- reference_list=reference_list,)
+ while len(specialise_list) !=0:
+ child = specialise_list.pop(0)
+
+ # this should avoid circular dependencies
+ if child not in already_add_models:
+ already_add_models.append(child)
+ model_list.append(child)
+
return model_reference_dict
Modified: erp5/trunk/products/ERP5/Document/PaySheetTransaction.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PaySheetTransaction.py?rev=18344&r1=18343&r2=18344&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PaySheetTransaction.py (original)
+++ erp5/trunk/products/ERP5/Document/PaySheetTransaction.py Sat Dec 15 20:08:36 2007
@@ -399,13 +399,15 @@
0, tuple)
continue
- if len(cell.getVariationCategoryList(base_category_list='tax_category')):
- share = \
- cell.getVariationCategoryList(base_category_list='tax_category')[0]
-
- if len(cell.getVariationCategoryList(base_category_list='salary_range')):
- slice = \
- cell.getVariationCategoryList(base_category_list='salary_range')[0]
+ if len(cell.getVariationCategoryList(\
+ base_category_list='tax_category')):
+ share = cell.getVariationCategoryList(\
+ base_category_list='tax_category')[0]
+
+ if len(cell.getVariationCategoryList(\
+ base_category_list='salary_range')):
+ slice = cell.getVariationCategoryList(\
+ base_category_list='salary_range')[0]
# get the edited values if this model_line is editable
# and replace the original cell values by this ones
@@ -485,12 +487,6 @@
quantity = cell_dict['quantity']
price = cell_dict['price']
-# # Define an empty new cell
-# new_cell = { 'axe_list' : tuple, # share, slice
-# 'quantity' : quantity,
-# 'price' : price,
-# #'categories' : causality/machin_module/annotation_line,
-# }
cell_list.append(cell_dict)
# update the base_participation
@@ -539,12 +535,9 @@
'''
model = self.getSpecialiseValue()
- model_reference_dict={}
- model.getInheritanceModelReferenceDict(\
- model_reference_dict=model_reference_dict,
- model_list=model,
- portal_type_list=portal_type_list,
- reference_list=[])
+ model_reference_dict = \
+ model.getInheritanceModelReferenceDict(\
+ portal_type_list=portal_type_list)
# add line of base model without reference
model_dict = model.getReferenceDict(\
More information about the Erp5-report
mailing list