[ofbiz-framework] branch release18.12 updated: Fixed: Picklist is in Input status even after order is completed. (OFBIZ-10883)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch release18.12 updated: Fixed: Picklist is in Input status even after order is completed. (OFBIZ-10883)

surajk
This is an automated email from the ASF dual-hosted git repository.

surajk pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release18.12 by this push:
     new 9b3968e  Fixed: Picklist is in Input status even after order is completed. (OFBIZ-10883)
9b3968e is described below

commit 9b3968ef11e55ee552199a4491dab8d08b25e674
Author: Suraj Khurana <[hidden email]>
AuthorDate: Wed Feb 26 19:25:25 2020 +0530

    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.
---
 .../datamodel/entitydef/shipment-entitymodel.xml   | 11 ++++++++
 .../ofbiz/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 fcd3cc9..9232fdd 100644
--- a/applications/datamodel/entitydef/shipment-entitymodel.xml
+++ b/applications/datamodel/entitydef/shipment-entitymodel.xml
@@ -191,6 +191,17 @@ under the License.
         <key-map field-name="picklistBinId"/>
       </view-link>
     </view-entity>
+    <view-entity entity-name="PicklistAndBin"
+                 package-name="org.apache.ofbiz.shipment.picklist"
+                 title="Picklist and PicklistBin View">
+      <member-entity entity-alias="PL" entity-name="Picklist"/>
+      <member-entity entity-alias="PLB" entity-name="PicklistBin"/>
+      <alias-all entity-alias="PL"/>
+      <alias-all entity-alias="PLB"/>
+      <view-link entity-alias="PL" rel-entity-alias="PLB">
+        <key-map field-name="picklistId"/>
+      </view-link>
+    </view-entity>
     <entity entity-name="PicklistBin"
             package-name="org.apache.ofbiz.shipment.picklist"
             title="Picklist">
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 359212b..0cb5f46 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<String, Object> 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<GenericValue> 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<String, Object> 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