From 39cc830c2f6a9951db367d3e5f079b6980a30ddc Mon Sep 17 00:00:00 2001 From: Suraj Khurana Date: Wed, 26 Feb 2020 19:22:49 +0530 Subject: [PATCH] Fixed: Picklist is in Input status even after order is completed. (OFBIZ-10883) Thanks Rashi Dhagat for reporting, Shikha Jaiswal for the patch and Pawan Verma for review. --- .../entitydef/shipment-entitymodel.xml | 11 +++++++ .../shipment/packing/PackingSession.java | 29 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/applications/datamodel/entitydef/shipment-entitymodel.xml b/applications/datamodel/entitydef/shipment-entitymodel.xml index cf3bc74c82..354cd6a64a 100644 --- a/applications/datamodel/entitydef/shipment-entitymodel.xml +++ b/applications/datamodel/entitydef/shipment-entitymodel.xml @@ -193,6 +193,17 @@ under the License. + + + + + + + + + diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java index a7830b2b52..2bf0ac2922 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java @@ -674,6 +674,8 @@ public class PackingSession implements java.io.Serializable { this.setShipmentToPacked(); // set role on picklist this.setPickerOnPicklist(); + // set picklist to picked + this.setPicklistToPicked(); // run the complete events this.runEvents(PackingEvent.EVENT_CODE_COMPLETE); @@ -865,6 +867,33 @@ public class PackingSession implements java.io.Serializable { } } + protected void setPicklistToPicked() throws GeneralException { + Delegator delegator = this.getDelegator(); + if (picklistBinId != null) { + GenericValue picklist = EntityQuery.use(delegator).from("PicklistAndBin").where("picklistBinId", picklistBinId).queryFirst(); + if (picklist == null) { + if (!"PICKLIST_PICKED".equals(picklist.getString("statusId")) && !"PICKLIST_COMPLETED".equals(picklist.getString("statusId")) && !"PICKLIST_CANCELLED".equals(picklist.getString("statusId"))) { + Map serviceResult = this.getDispatcher().runSync("updatePicklist", UtilMisc.toMap("picklistId", picklist.getString("picklistId"), "statusId", "PICKLIST_PICKED", "userLogin", userLogin)); + if (!ServiceUtil.isSuccess(serviceResult)) { + throw new GeneralException(ServiceUtil.getErrorMessage(serviceResult)); + } + } + } + } else { + List picklistBins = EntityQuery.use(delegator).from("PicklistAndBin").where("primaryOrderId", primaryOrderId).queryList(); + if (UtilValidate.isNotEmpty(picklistBins)) { + for (GenericValue picklistBin : picklistBins) { + if (!"PICKLIST_PICKED".equals(picklistBin.getString("statusId")) && !"PICKLIST_COMPLETED".equals(picklistBin.getString("statusId")) && !"PICKLIST_CANCELLED".equals(picklistBin.getString("statusId"))) { + Map serviceResult = this.getDispatcher().runSync("updatePicklist", UtilMisc.toMap("picklistId", picklistBin.getString("picklistId"), "statusId", "PICKLIST_PICKED", "userLogin", userLogin)); + if (!ServiceUtil.isSuccess(serviceResult)) { + throw new GeneralException(ServiceUtil.getErrorMessage(serviceResult)); + } + } + } + } + } + } + protected void setPickerOnPicklist() throws GeneralException { if (picklistBinId != null) { // first find the picklist id