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'):
movement_to_update.getAggregateValueList() + [item])
update_quantity = not context.Movement_isQuantityEditable()
if update_quantity:
if context.isMovement():
movement_list = context,
else:
movement_list = context.getCellValueList(base_id='movement')
for movement in movement_list:
quantity = 0
item_list = movement.getAggregateValueList()
for item in item_list:
if item.getQuantityUnit() != movement.getQuantityUnit():
if len(item_list) > 1:
raise NotImplementedError(
'Quantity unit from the movement differs from quantity'
' unit on the item')
quantity += item.getQuantity(at_date=DateTime())
movement.setQuantity(quantity)
if context.isMovement():
movement_list = context,
else:
movement_list = context.getCellValueList(base_id='movement')
for movement in movement_list:
quantity = 0
item_list = movement.getAggregateValueList()
for item in item_list:
if item.getQuantityUnit() != movement.getQuantityUnit():
if len(item_list) > 1:
raise NotImplementedError(
'Quantity unit from the movement differs from quantity'
' unit on the item')
quantity += item.getQuantity(at_date=DateTime())
movement.setQuantity(quantity)
return context.Base_redirect(form_id, keep_items=dict(
portal_status_message=translateString('Items created')))
......@@ -92,25 +92,23 @@ for item_uid in uids:
movement_to_update.setAggregateValueSet(
movement_to_update.getAggregateValueList() + [item])
update_quantity = not context.Movement_isQuantityEditable()
if update_quantity:
if context.isMovement():
movement_list = context,
else:
movement_list = context.getCellValueList(base_id='movement')
for movement in movement_list:
quantity = 0
item_list = movement.getAggregateValueList()
for item in item_list:
if item.getQuantityUnit() != movement.getQuantityUnit():
if len(item_list) > 1:
raise NotImplementedError(
'Quantity unit from the movement differs from quantity'
' unit on the item')
else:
movement.setQuantityUnit(item.getQuantityUnit())
quantity += item.getQuantity()
movement.setQuantity(quantity)
if context.isMovement():
movement_list = context,
else:
movement_list = context.getCellValueList(base_id='movement')
for movement in movement_list:
quantity = 0
item_list = movement.getAggregateValueList()
for item in item_list:
if item.getQuantityUnit() != movement.getQuantityUnit():
if len(item_list) > 1:
raise NotImplementedError(
'Quantity unit from the movement differs from quantity'
' unit on the item')
else:
movement.setQuantityUnit(item.getQuantityUnit())
quantity += item.getQuantity()
movement.setQuantity(quantity)
return context.Base_redirect(form_id, keep_items=dict(
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