Commit 56b4b95e authored by Łukasz Nowak's avatar Łukasz Nowak

erp5_item: Update quantity unconditionally

Since Movement_isQuantityEditable does not say anything about Item related
movements, there is no reason to use any condition while updating
quantities.
parent 91619838
...@@ -80,23 +80,21 @@ for line in kw.get('listbox'): ...@@ -80,23 +80,21 @@ for line in kw.get('listbox'):
movement_to_update.getAggregateValueList() + [item]) movement_to_update.getAggregateValueList() + [item])
update_quantity = not context.Movement_isQuantityEditable() if context.isMovement():
if update_quantity: movement_list = context,
if context.isMovement(): else:
movement_list = context, movement_list = context.getCellValueList(base_id='movement')
else: for movement in movement_list:
movement_list = context.getCellValueList(base_id='movement') quantity = 0
for movement in movement_list: item_list = movement.getAggregateValueList()
quantity = 0 for item in item_list:
item_list = movement.getAggregateValueList() if item.getQuantityUnit() != movement.getQuantityUnit():
for item in item_list: if len(item_list) > 1:
if item.getQuantityUnit() != movement.getQuantityUnit(): raise NotImplementedError(
if len(item_list) > 1: 'Quantity unit from the movement differs from quantity'
raise NotImplementedError( ' unit on the item')
'Quantity unit from the movement differs from quantity' quantity += item.getQuantity(at_date=DateTime())
' unit on the item') movement.setQuantity(quantity)
quantity += item.getQuantity(at_date=DateTime())
movement.setQuantity(quantity)
return context.Base_redirect(form_id, keep_items=dict( return context.Base_redirect(form_id, keep_items=dict(
portal_status_message=translateString('Items created'))) portal_status_message=translateString('Items created')))
...@@ -92,25 +92,23 @@ for item_uid in uids: ...@@ -92,25 +92,23 @@ for item_uid in uids:
movement_to_update.setAggregateValueSet( movement_to_update.setAggregateValueSet(
movement_to_update.getAggregateValueList() + [item]) movement_to_update.getAggregateValueList() + [item])
update_quantity = not context.Movement_isQuantityEditable() if context.isMovement():
if update_quantity: movement_list = context,
if context.isMovement(): else:
movement_list = context, movement_list = context.getCellValueList(base_id='movement')
else: for movement in movement_list:
movement_list = context.getCellValueList(base_id='movement') quantity = 0
for movement in movement_list: item_list = movement.getAggregateValueList()
quantity = 0 for item in item_list:
item_list = movement.getAggregateValueList() if item.getQuantityUnit() != movement.getQuantityUnit():
for item in item_list: if len(item_list) > 1:
if item.getQuantityUnit() != movement.getQuantityUnit(): raise NotImplementedError(
if len(item_list) > 1: 'Quantity unit from the movement differs from quantity'
raise NotImplementedError( ' unit on the item')
'Quantity unit from the movement differs from quantity' else:
' unit on the item') movement.setQuantityUnit(item.getQuantityUnit())
else: quantity += item.getQuantity()
movement.setQuantityUnit(item.getQuantityUnit()) movement.setQuantity(quantity)
quantity += item.getQuantity()
movement.setQuantity(quantity)
return context.Base_redirect(form_id, keep_items=dict( return context.Base_redirect(form_id, keep_items=dict(
portal_status_message=translateString('Items aggregated'))) portal_status_message=translateString('Items aggregated')))
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