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): ...@@ -88,34 +88,32 @@ class TradeCondition(Path, Transformation):
# check if the existing movements are in aggregated movments # check if the existing movements are in aggregated movments
movement_to_delete_list = [] movement_to_delete_list = []
movement_to_add_list = [] movement_to_add_list = []
if len(aggregated_amount_list): for movement in existing_movement_list:
for movement in existing_movement_list: keep_movement = False
keep_movement = False # here we have to check if the movement is a generated one or
for amount in aggregated_amount_list: # entered by the user. If it has been entered by user, we have to
# here we have to check if the movement is a generated one or # keep it.
# entered by the user. If it has been entered by user, we have to resource = movement.getResourceValue()
# keep it. if resource is not None and \
# if movement is generated and if not exist, append to delete list len(set(normal_use_list).intersection(set(resource\
# else, break .getUseList()))):
resource = movement.getResourceValue() keep_movement = True
if resource is not None and \ break
len(set(normal_use_list).intersection(set(resource\ for amount in aggregated_amount_list:
.getUseList()))): # if movement is generated and if not exist, append to delete list
keep_movement = True update_kw = {}
break for p in self.edited_property_list:
update_kw = {} update_kw[p] = amount.getProperty(p)
for p in self.edited_property_list: if movement.getProperty('resource') == update_kw['resource'] and\
update_kw[p] = amount.getProperty(p) movement.getVariationCategoryList() == \
if movement.getProperty('resource') == update_kw['resource'] and\ amount.getVariationCategoryList():
movement.getVariationCategoryList() == \ movement.edit(**update_kw)
amount.getVariationCategoryList(): modified_resource_list.append(update_kw['resource'])
movement.edit(**update_kw) keep_movement = True
modified_resource_list.append(update_kw['resource']) if not keep_movement:
keep_movement = True movement_to_delete_list.append(movement)
if not keep_movement: movement_to_add_list = [amount for amount in aggregated_amount_list if
movement_to_delete_list.append(movement) amount.getResource() not in modified_resource_list]
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, return {'movement_to_delete_list' : movement_to_delete_list,
'movement_to_add_list': movement_to_add_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