Commit 76e8d606 authored by Fabien Morin's avatar Fabien Morin

- 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.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18344 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7306b7af
......@@ -33,6 +33,8 @@ from Products.ERP5.Document.TradeCondition import TradeCondition
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 @@ class PaySheetModel(TradeCondition, XMLMatrix):
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:
model_reference_list=model.getReferenceDict(portal_type_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)
for reference in model_reference_list.keys():
if reference not in reference_list:
reference_list.append(reference)
......@@ -117,10 +124,12 @@ class PaySheetModel(TradeCondition, XMLMatrix):
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
......@@ -399,13 +399,15 @@ class PaySheetTransaction(Invoice):
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='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='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 @@ class PaySheetTransaction(Invoice):
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 @@ class PaySheetTransaction(Invoice):
'''
model = self.getSpecialiseValue()
model_reference_dict={}
model_reference_dict = \
model.getInheritanceModelReferenceDict(\
model_reference_dict=model_reference_dict,
model_list=model,
portal_type_list=portal_type_list,
reference_list=[])
portal_type_list=portal_type_list)
# add line of base model without reference
model_dict = model.getReferenceDict(\
......
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