You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Mridul Pathak (Jira)" <ji...@apache.org> on 2026/09/04 07:32:00 UTC
[jira] [Closed] (OFBIZ-13520) createOrderShipmentPlan leaks order items across ship groups
[ https://issues.apache.org/jira/browse/OFBIZ-13520?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mridul Pathak closed OFBIZ-13520.
---------------------------------
Fix Version/s: Upcoming Branch
24.09.08
Resolution: Fixed
> createOrderShipmentPlan leaks order items across ship groups
> ------------------------------------------------------------
>
> Key: OFBIZ-13520
> URL: https://issues.apache.org/jira/browse/OFBIZ-13520
> Project: OFBiz
> Issue Type: Bug
> Components: product
> Affects Versions: Upcoming Branch, 24.09.07
> Reporter: Mridul Pathak
> Assignee: Mridul Pathak
> Priority: Major
> Fix For: Upcoming Branch, 24.09.08
>
>
> h3. Problem
> {{createOrderShipmentPlan}} in {{applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentServices.groovy}} creates one {{Shipment}} per {{OrderItemShipGroup}}, but for each shipment it plans every {{OrderItem}} on the order, not just the items associated with that particular ship group:
> {code:java}
> List orderItems = orderHeader.getRelated('OrderItem', null, null, false)
> orderItems.each { GenericValue orderItem ->
> ...
> run service: 'addOrderShipmentToShipment', with: [orderId: orderHeader.orderId,
> orderItemSeqId: orderItem.orderItemSeqId,
> shipmentId: shipment.shipmentId,
> shipGroupSeqId: orderItemShipGroup.shipGroupSeqId,
> quantity: orderItem.quantity]
> }
> {code}
> On a multi-ship-group order, this plans items onto shipments for ship groups they do not belong to, and uses the order item's total quantity rather than the quantity actually associated with that ship group. This is the same class of bug as OFBIZ-5346 / OFBIZ-11462, which were fixed for {{quickShipEntireOrder}} but not for {{createOrderShipmentPlan}}.
> h3. Fix
> Scope the inner loop to {{OrderItemAndShipGroupAssoc}} records for the current ship group (grouped by {{shipGroupSeqId}} up front, mirroring the {{getOrderItemShipGroupLists}} / {{createShipmentForFacilityAndShipGroup}} pattern already used by {{quickShipEntireOrder}}), use the assoc's quantity instead of the order item's total quantity, and skip a ship group entirely when it has no associated items.
> h3. Acceptance criteria
> - On an order with multiple ship groups, each shipment's {{OrderShipment}} rows reference only the order items actually associated with that shipment's {{primaryShipGroupSeqId}}, at the correct per-group quantity.
> - A ship group with no associated order items does not get a shipment created for it.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)