Fixes Issue 27735:Stock Reservation cannot be manually done if there exist
authorAtul Gaware <atul.gaware@openbravo.com>
Tue, 07 Oct 2014 11:58:37 +0530
changeset 24077 ba2eb656f29e
parent 24076 541489ec5169
child 24078 9f64a8da1daa
Fixes Issue 27735:Stock Reservation cannot be manually done if there exist
pending purchase orders for that product

query created was for orderline but code seems to be incorrect so removed
wrong part which was trying to cast the result to Storage Detail
src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java
--- a/src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java	Fri Oct 03 13:12:58 2014 +0200
+++ b/src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java	Tue Oct 07 11:58:37 2014 +0530
@@ -889,80 +889,49 @@
     }
     for (Object o : query.list()) {
       Map<String, Object> myMap = new HashMap<String, Object>();
-      StorageDetail sd = (StorageDetail) o;
-      if (selectedIds.size() > 0) {
-        for (int i = 0; i < selectedIds.size(); i++) {
-          if (!sd.getId().equals(selectedIds.get(i))) {
+      OrderLine orderLine = (OrderLine) o;
+      myMap.put("id", orderLine.getId());
+      myMap.put("obSelected", false);
+      myMap.put("reservationStock", null);
+      myMap.put("reservationStock$_identifier", "");
+      myMap.put("storageBin$_identifier", "");
+      myMap.put("storageBin", "");
+      myMap.put("warehouse", (orderLine.getSalesOrder().getWarehouse() != null) ? orderLine
+          .getSalesOrder().getWarehouse().getId() : null);
+      myMap.put("warehouse$_identifier",
+          (orderLine.getSalesOrder().getWarehouse() != null) ? orderLine.getSalesOrder()
+              .getWarehouse().getIdentifier() : "");
+      myMap.put("attributeSetValue", orderLine.getAttributeSetValue() != null ? orderLine
+          .getAttributeSetValue().getId() : null);
+      myMap.put("attributeSetValue$_identifier",
+          orderLine.getAttributeSetValue() != null ? orderLine.getAttributeSetValue()
+              .getIdentifier() : "");
+      myMap.put("purchaseOrderLine", orderLine.getId());
+      myMap.put("purchaseOrderLine$_identifier", orderLine.getIdentifier());
+      // Check Filter Criterias
 
-            // Check Filter Criterias
-            if (availableQtyFilterCriteria != null && !"".equals(availableQtyFilterCriteria)
-                && !isInScope("availableQty", availableQtyFilterCriteria, sd.getQuantityOnHand())) {
-              continue;
-            }
-            BigDecimal reservedinothers = getQtyReserved(reservation, reservation.getProduct(),
-                sd.getAttributeSetValue(), sd.getStorageBin());
-
-            if (reservedinothersFilterCriteria != null
-                && !"".equals(reservedinothersFilterCriteria)
-                && !isInScope("reservedinothers", reservedinothersFilterCriteria, reservedinothers)) {
-              continue;
-            }
-            if (releasedFilterCriteria != null && !"".equals(releasedFilterCriteria)
-                && !isInScope("released", releasedFilterCriteria, BigDecimal.ZERO)) {
-              continue;
-            }
-            result = tomap(sd, false, result, reservedinothers, reservation);
-          }
-        }
-      } else {
-
-        OrderLine orderLine = (OrderLine) o;
-        myMap.put("id", orderLine.getId());
-        myMap.put("obSelected", false);
-        myMap.put("reservationStock", null);
-        myMap.put("reservationStock$_identifier", "");
-        myMap.put("storageBin$_identifier", "");
-        myMap.put("storageBin", "");
-        myMap.put("warehouse", (orderLine.getSalesOrder().getWarehouse() != null) ? orderLine
-            .getSalesOrder().getWarehouse().getId() : null);
-        myMap.put("warehouse$_identifier",
-            (orderLine.getSalesOrder().getWarehouse() != null) ? orderLine.getSalesOrder()
-                .getWarehouse().getIdentifier() : "");
-        myMap.put("attributeSetValue", orderLine.getAttributeSetValue() != null ? orderLine
-            .getAttributeSetValue().getId() : null);
-        myMap.put("attributeSetValue$_identifier",
-            orderLine.getAttributeSetValue() != null ? orderLine.getAttributeSetValue()
-                .getIdentifier() : "");
-        myMap.put("purchaseOrderLine", orderLine.getId());
-        myMap.put("purchaseOrderLine$_identifier", orderLine.getIdentifier());
-        // Check Filter Criterias
-
-        if (availableQtyFilterCriteria != null
-            && !"".equals(availableQtyFilterCriteria)
-            && !isInScope("availableQty", availableQtyFilterCriteria,
-                orderLine.getOrderedQuantity())) {
-          continue;
-        }
-        BigDecimal reservedinothers = getQtyReserved(reservation, orderLine);
-        if (reservedinothersFilterCriteria != null && !"".equals(reservedinothersFilterCriteria)
-            && !isInScope("reservedinothers", reservedinothersFilterCriteria, reservedinothers)) {
-          continue;
-        }
-        if (releasedFilterCriteria != null && !"".equals(releasedFilterCriteria)
-            && !isInScope("released", releasedFilterCriteria, BigDecimal.ZERO)) {
-          continue;
-        }
-        myMap.put("availableQty",
-            orderLine.getOrderedQuantity().subtract(getDeliveredQuantity(orderLine)));
-        myMap.put("reservedinothers", reservedinothers);
-        myMap.put("quantity", BigDecimal.ZERO);
-        myMap.put("reservationQuantity", reservation.getQuantity());
-        myMap.put("released", BigDecimal.ZERO);
-        myMap.put("allocated", false);
-        result.add(myMap);
+      if (availableQtyFilterCriteria != null && !"".equals(availableQtyFilterCriteria)
+          && !isInScope("availableQty", availableQtyFilterCriteria, orderLine.getOrderedQuantity())) {
+        continue;
       }
+      BigDecimal reservedinothers = getQtyReserved(reservation, orderLine);
+      if (reservedinothersFilterCriteria != null && !"".equals(reservedinothersFilterCriteria)
+          && !isInScope("reservedinothers", reservedinothersFilterCriteria, reservedinothers)) {
+        continue;
+      }
+      if (releasedFilterCriteria != null && !"".equals(releasedFilterCriteria)
+          && !isInScope("released", releasedFilterCriteria, BigDecimal.ZERO)) {
+        continue;
+      }
+      myMap.put("availableQty",
+          orderLine.getOrderedQuantity().subtract(getDeliveredQuantity(orderLine)));
+      myMap.put("reservedinothers", reservedinothers);
+      myMap.put("quantity", BigDecimal.ZERO);
+      myMap.put("reservationQuantity", reservation.getQuantity());
+      myMap.put("released", BigDecimal.ZERO);
+      myMap.put("allocated", false);
+      result.add(myMap);
     }
-
     return result;
   }