Order and all items are in approved status. Wait one day. Click on Edit/Add Items and change the amount of one item. Then click Update Items. Result: The order and all Items have completed status!
Maybe this can be reproduced only by updating the item amount twice, as it was the case when observed the above behaviour.
Expected Result would be: Only the amount is recalculated and order as well as order items keep their status.
Some parts from the log that may be interesting:
ControlServlet.java:145:INFO ] [[[updateOrderItems] Request Begun
OrderServices.java:837:INFO ] updateOrderItems: found filtered item = ...
-> This occurs only once, why not 4 times? And the item is not the one that has changed quantity
ShoppingCartServices.java:467:INFO ] No payment preferences found for order #SC139
OrderServices.java:1763:INFO ] To Store Contains: [[GenericEntity:OrderItem][
-> here everything seems to be o.k. statusIds are all ITEM_APPROVED.
[PaymentGatewayServices.java:729:WARN ] No OrderPaymentPreference records available for release
[ServiceEcaCondition.java:156:WARN ] From Field (orderTypeId) is not found in context for updateOrderItems, defaulting to null.
-> ???
ServiceEcaRule.java:164:INFO ] Running Service ECA Service: checkOrderItemStatus, triggered by rule on Service: changeOrderItemStatus
ServiceEcaRule.java:147:INFO ] For Service ECA [changeOrderItemStatus] on [commit] got false for condition: [statusId][equals][ITEM_APPROVED][true][String]
-> several times, also with same or other statusTypes
I have now found the code that makes the trouble. In org.opentaps.common.order.OrderServices you find around line 913:
if (item.getRemainingToShipQuantity().signum() == 0) {
...
}
It seems that the remainingToShipQuantity is not a valid indicator if an item should be set to completed as for service items this is (is it??) always zero.
It does not make sense to change the item status when the user only requests a change in item quantity.
I suppose all orders that contain service items are concerned by this.
And .. update:
I dived deeper and I saw that there may be many situations where the shipped amount is zero. First I thought I could distinct by the order item type but I realized that this field is set in some random manner (another bug?).
So my suggestion is to remove the complete part that marks the completes the items in updateApprovedOrderItems as it makes no sense to update them while the items are updated.
If there are side effects, please add comment.