Commit e5b57fd7 authored by Fabien Morin's avatar Fabien Morin

get subobject using model dependance tree


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18333 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dee54adf
...@@ -91,10 +91,9 @@ class PaySheetModel(TradeCondition, XMLMatrix): ...@@ -91,10 +91,9 @@ class PaySheetModel(TradeCondition, XMLMatrix):
if reference is not None and not get_none_reference: if reference is not None and not get_none_reference:
reference_dict[reference]=object.getId() reference_dict[reference]=object.getId()
elif reference is None and get_none_reference: elif reference is None and get_none_reference:
reference_dict[reference]=object.getId() reference_dict[object.getId()]=object.getId()
else: else:
LOG('PaySheetModel getReferenceList', 0, '%s reference ' LOG('PaySheetModel getReferenceList', 0, '"%s" reference '
'property is empty' % object.getTitle() or 'property is empty' % object.getTitle() or
object.getRelativeUrl()) object.getRelativeUrl())
......
...@@ -77,8 +77,11 @@ class PaySheetTransaction(Invoice): ...@@ -77,8 +77,11 @@ class PaySheetTransaction(Invoice):
return the ratio value correponding to the ratio_reference, return the ratio value correponding to the ratio_reference,
None if ratio_reference not found None if ratio_reference not found
""" """
object_ratio_list = self.contentValues(portal_type=\ # get ratio lines
'Pay Sheet Model Ratio Line') portal_type_list = ['Pay Sheet Model Ratio Line']
sub_object_list = self.getSubObjectValueList(portal_type_list)
object_ratio_list = sub_object_list
for object in object_ratio_list: for object in object_ratio_list:
if object.getReference() == ratio_reference: if object.getReference() == ratio_reference:
return object.getQuantity() return object.getQuantity()
...@@ -104,7 +107,11 @@ class PaySheetTransaction(Invoice): ...@@ -104,7 +107,11 @@ class PaySheetTransaction(Invoice):
return the annotation line correponding to the reference, return the annotation line correponding to the reference,
None if reference not found None if reference not found
""" """
annotation_line_list = self.contentValues(portal_type='Annotation Line') # get Annotation Lines
portal_type_list = ['Annotation Line']
sub_object_list = self.getSubObjectValueList(portal_type_list)
annotation_line_list = sub_object_list
for annotation_line in annotation_line_list: for annotation_line in annotation_line_list:
if annotation_line.getReference() == reference: if annotation_line.getReference() == reference:
return annotation_line return annotation_line
...@@ -236,7 +243,15 @@ class PaySheetTransaction(Invoice): ...@@ -236,7 +243,15 @@ class PaySheetTransaction(Invoice):
return the not editable lines as dict return the not editable lines as dict
''' '''
model = paysheet.getSpecialiseValue() model = paysheet.getSpecialiseValue()
model_line_list = model.contentValues(portal_type='Pay Sheet Model Line')
def sortByIntIndex(a, b):
return cmp(a.getIntIndex(), b.getIntIndex())
# get model lines
portal_type_list = ['Pay Sheet Model Line']
sub_object_list = paysheet.getSubObjectValueList(portal_type_list)
sub_object_list.sort(sortByIntIndex)
model_line_list = sub_object_list
model_line_dict = {} model_line_dict = {}
for model_line in model_line_list: for model_line in model_line_list:
...@@ -300,6 +315,8 @@ class PaySheetTransaction(Invoice): ...@@ -300,6 +315,8 @@ class PaySheetTransaction(Invoice):
# current_amount = base_amount_dict[base_amount][share] # current_amount = base_amount_dict[base_amount][share]
base_amount_dict = {} base_amount_dict = {}
model = paysheet.getSpecialiseValue()
def sortByIntIndex(a, b): def sortByIntIndex(a, b):
return cmp(a.getIntIndex(), b.getIntIndex()) return cmp(a.getIntIndex(), b.getIntIndex())
...@@ -309,9 +326,10 @@ class PaySheetTransaction(Invoice): ...@@ -309,9 +326,10 @@ class PaySheetTransaction(Invoice):
# get model lines # get model lines
model = paysheet.getSpecialiseValue() portal_type_list = ['Pay Sheet Model Line']
model_line_list = model.contentValues(portal_type='Pay Sheet Model Line', sub_object_list = paysheet.getSubObjectValueList(portal_type_list)
sort_on='int_index') sub_object_list.sort(sortByIntIndex)
model_line_list = sub_object_list
pay_sheet_line_list = [] pay_sheet_line_list = []
...@@ -505,16 +523,16 @@ class PaySheetTransaction(Invoice): ...@@ -505,16 +523,16 @@ class PaySheetTransaction(Invoice):
model_list=model, model_list=model,
portal_type_list=portal_type_list, portal_type_list=portal_type_list,
reference_list=[]) reference_list=[])
pprint.pformat(model_reference_dict))
# add line of base model without reference # add line of base model without reference
model_dict = model.getReferenceDict(\ model_dict = model.getReferenceDict(\
portal_type_list=portal_type_list, portal_type_list=portal_type_list,
get_none_reference=1) get_none_reference=1)
id_list = model_dict.values() id_list = model_dict.values()
model_reference_dict[model.getRelativeUrl()].extend(id_list) if model_reference_dict.has_key(model.getRelativeUrl()):
pprint.pformat(model_reference_dict)) model_reference_dict[model.getRelativeUrl()].extend(id_list)
else:
model_reference_dict[model.getRelativeUrl()]=id_list
# get sub objects # get sub objects
key_list = model_reference_dict.keys() key_list = model_reference_dict.keys()
......
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