Commit 16166dca authored by Łukasz Nowak's avatar Łukasz Nowak

- updateAggregatedAmountList shall update what is existing and return list of not found amounts


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26692 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c4fe81fa
...@@ -66,25 +66,21 @@ class TradeCondition(Path, Transformation): ...@@ -66,25 +66,21 @@ class TradeCondition(Path, Transformation):
, PropertySheet.Order , PropertySheet.Order
) )
def updateAggregatedAmountList(self, context, destination_portal_type, **kw): def updateAggregatedAmountList(self, context, **kw):
# XXX: Shall not create new, only update existing and return new existing_movement_list = context.contentValues()
existing_object_list = context.objectValues(portal_type=destination_portal_type) aggregated_amount_list = self.getAggregatedAmountList(context = context,
for o in self.getAggregatedAmountList(context = context, **kw): **kw)
modified_resource_list = []
for amount in aggregated_amount_list:
update_kw = {} update_kw = {}
create_new = 1
for p in self.edited_property_list: for p in self.edited_property_list:
update_kw[p] = o.getProperty(p) update_kw[p] = amount.getProperty(p)
for e in existing_object_list: for movement in existing_movement_list:
if e.getProperty('resource') == o.getProperty('resource'): if movement.getProperty('resource') == update_kw['resource']:
# we need to update existing movement.edit(**update_kw)
e.edit(**update_kw) modified_resource_list.append(update_kw['resource'])
create_new = 0 return [amount for amount in aggregated_amount_list if
break amount.getResource() not in modified_resource_list]
if create_new:
context.newContent(
portal_type = destination_portal_type,
**update_kw
)
def getAggregatedAmountList(self, context, **kw): def getAggregatedAmountList(self, context, **kw):
result = AggregatedAmountList() result = AggregatedAmountList()
......
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