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 ...@@ -33,6 +33,8 @@ from Products.ERP5.Document.TradeCondition import TradeCondition
from Products.ERP5Type.XMLMatrix import XMLMatrix from Products.ERP5Type.XMLMatrix import XMLMatrix
from zLOG import LOG, WARNING, DEBUG 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): class PaySheetModel(TradeCondition, XMLMatrix):
""" """
...@@ -95,20 +97,25 @@ class PaySheetModel(TradeCondition, XMLMatrix): ...@@ -95,20 +97,25 @@ class PaySheetModel(TradeCondition, XMLMatrix):
return reference_dict return reference_dict
def getInheritanceModelReferenceDict(self, model_reference_dict, def getInheritanceModelReferenceDict(self, portal_type_list):
model_list, portal_type_list, reference_list):
''' '''
return a dict with the model url as key and a list of reference 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 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 model = self
if type(model_list) != type([]): already_add_models = [model]
model_list = [model_list,] model_list = [model]
model_reference_dict = {}
reference_list = []
id_list = []
for model in model_list: while len(model_list) != 0:
model_reference_list=model.getReferenceDict(portal_type_list) model = model_list.pop(0)
id_list = [] id_list = []
specialise_list = model.getSpecialiseValueList()
model_reference_list=model.getReferenceDict(portal_type_list)
for reference in model_reference_list.keys(): for reference in model_reference_list.keys():
if reference not in reference_list: if reference not in reference_list:
reference_list.append(reference) reference_list.append(reference)
...@@ -117,10 +124,12 @@ class PaySheetModel(TradeCondition, XMLMatrix): ...@@ -117,10 +124,12 @@ class PaySheetModel(TradeCondition, XMLMatrix):
if id_list != []: if id_list != []:
model_reference_dict[model.getRelativeUrl()]=id_list model_reference_dict[model.getRelativeUrl()]=id_list
new_model_list = model.getSpecialiseValueList() while len(specialise_list) !=0:
self.getInheritanceModelReferenceDict(\ child = specialise_list.pop(0)
model_reference_dict=model_reference_dict,
model_list=new_model_list, # this should avoid circular dependencies
portal_type_list=portal_type_list, if child not in already_add_models:
reference_list=reference_list,) already_add_models.append(child)
model_list.append(child)
return model_reference_dict return model_reference_dict
...@@ -399,13 +399,15 @@ class PaySheetTransaction(Invoice): ...@@ -399,13 +399,15 @@ class PaySheetTransaction(Invoice):
0, tuple) 0, tuple)
continue continue
if len(cell.getVariationCategoryList(base_category_list='tax_category')): if len(cell.getVariationCategoryList(\
share = \ base_category_list='tax_category')):
cell.getVariationCategoryList(base_category_list='tax_category')[0] share = cell.getVariationCategoryList(\
base_category_list='tax_category')[0]
if len(cell.getVariationCategoryList(base_category_list='salary_range')): if len(cell.getVariationCategoryList(\
slice = \ base_category_list='salary_range')):
cell.getVariationCategoryList(base_category_list='salary_range')[0] slice = cell.getVariationCategoryList(\
base_category_list='salary_range')[0]
# get the edited values if this model_line is editable # get the edited values if this model_line is editable
# and replace the original cell values by this ones # and replace the original cell values by this ones
...@@ -485,12 +487,6 @@ class PaySheetTransaction(Invoice): ...@@ -485,12 +487,6 @@ class PaySheetTransaction(Invoice):
quantity = cell_dict['quantity'] quantity = cell_dict['quantity']
price = cell_dict['price'] 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) cell_list.append(cell_dict)
# update the base_participation # update the base_participation
...@@ -539,12 +535,9 @@ class PaySheetTransaction(Invoice): ...@@ -539,12 +535,9 @@ class PaySheetTransaction(Invoice):
''' '''
model = self.getSpecialiseValue() model = self.getSpecialiseValue()
model_reference_dict={} model_reference_dict = \
model.getInheritanceModelReferenceDict(\ model.getInheritanceModelReferenceDict(\
model_reference_dict=model_reference_dict, portal_type_list=portal_type_list)
model_list=model,
portal_type_list=portal_type_list,
reference_list=[])
# add line of base model without reference # add line of base model without reference
model_dict = model.getReferenceDict(\ 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