From 541aadb69c5d03e1657be0733d14cdf064ac5def Mon Sep 17 00:00:00 2001 From: Arun Patidar Date: Tue, 28 Apr 2026 15:48:39 +0530 Subject: [PATCH] Fixed issue in Canceling an item from the order view and refreshing the page causes promotional items to endlessly duplicate in the ITEM_CREATED status.(OFBIZ-12104) --- .../order/order/OrderServicesScript.groovy | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderServicesScript.groovy b/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderServicesScript.groovy index c2fd7b665d..d4e755c41b 100644 --- a/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderServicesScript.groovy +++ b/applications/order/src/main/groovy/org/apache/ofbiz/order/order/OrderServicesScript.groovy @@ -31,7 +31,6 @@ import org.apache.ofbiz.order.shoppingcart.ShoppingCart import org.apache.ofbiz.order.shoppingcart.ShoppingCartItem import java.sql.Timestamp - /** * Service to create OrderHeader */ @@ -214,21 +213,37 @@ Map recreateOrderAdjustments() { // a new order item is created GenericValue newOrderItem = makeValue('OrderItem') newOrderItem.with { - orderId = parameters.orderId + orderId = order.get("orderId") orderItemTypeId = item.getItemType() selectedAmount = item.getSelectedAmount() unitPrice = item.getBasePrice() unitListPrice = item.getListPrice() - itemDescription = item.getName(dispatcher) + itemDescription = item.getDescription() statusId = item.getStatusId() productId = item.getProductId() quantity = item.getQuantity() isModifiedPrice = 'N' isPromo = 'Y' - statusId = newOrderItem.statusId ?: 'ITEM_CREATED' + statusId = order.statusId == 'ORDER_APPROVED' ? 'ITEM_APPROVED' : 'ITEM_CREATED' } newOrderItem.orderItemSeqId = delegator.getNextSeqId('OrderItem') newOrderItem.create() + + // create the OrderItemShipGroupAssoc + int itemIndex = cart.getItemIndex(item) + int shipGroupIndex = cart.getItemShipGroupIndex(itemIndex) + def csi = cart.getShipInfo(shipGroupIndex) + String shipGroupSeqId = csi.getShipGroupSeqId() + + GenericValue newOisga = makeValue('OrderItemShipGroupAssoc') + newOisga.with { + orderId = order.orderId + orderItemSeqId = newOrderItem.orderItemSeqId + shipGroupSeqId = shipGroupSeqId + quantity = newOrderItem.quantity + } + newOisga.create() + // And the orderItemSeqId is assigned to the shopping cart item item.setOrderItemSeqId(newOrderItem.orderItemSeqId) }