Commit bbff3abd authored by Fabien Morin's avatar Fabien Morin

fix a bug : aggregated_amount_list can be empty in the case all movements...

fix a bug : aggregated_amount_list can be empty in the case all movements should be removed. So we have to enter in the loop to put all movements in movement_to_delete_list


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27524 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a9f02ede
......@@ -88,34 +88,32 @@ class TradeCondition(Path, Transformation):
# check if the existing movements are in aggregated movments
movement_to_delete_list = []
movement_to_add_list = []
if len(aggregated_amount_list):
for movement in existing_movement_list:
keep_movement = False
for amount in aggregated_amount_list:
# 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.
# if movement is generated and if not exist, append to delete list
# else, break
resource = movement.getResourceValue()
if resource is not None and \
len(set(normal_use_list).intersection(set(resource\
.getUseList()))):
keep_movement = True
break
update_kw = {}
for p in self.edited_property_list:
update_kw[p] = amount.getProperty(p)
if movement.getProperty('resource') == update_kw['resource'] and\
movement.getVariationCategoryList() == \
amount.getVariationCategoryList():
movement.edit(**update_kw)
modified_resource_list.append(update_kw['resource'])
keep_movement = True
if not keep_movement:
movement_to_delete_list.append(movement)
movement_to_add_list = [amount for amount in aggregated_amount_list if
amount.getResource() not in modified_resource_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.
resource = movement.getResourceValue()
if resource is not None and \
len(set(normal_use_list).intersection(set(resource\
.getUseList()))):
keep_movement = True
break
for amount in aggregated_amount_list:
# if movement is generated and if not exist, append to delete list
update_kw = {}
for p in self.edited_property_list:
update_kw[p] = amount.getProperty(p)
if movement.getProperty('resource') == update_kw['resource'] and\
movement.getVariationCategoryList() == \
amount.getVariationCategoryList():
movement.edit(**update_kw)
modified_resource_list.append(update_kw['resource'])
keep_movement = True
if not keep_movement:
movement_to_delete_list.append(movement)
movement_to_add_list = [amount for amount in aggregated_amount_list if
amount.getResource() not in modified_resource_list]
return {'movement_to_delete_list' : movement_to_delete_list,
'movement_to_add_list': movement_to_add_list}
......
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