Fixes issue 32392: Wrong value in qtyreserved column of m_storage_pending in sales quotation.
authorMark <m.molina@nectus.com>
Mon, 28 Mar 2016 12:44:57 -0400
changeset 28844 8f219033b0d8
parent 28843 69d33f65c988
child 28845 b678870f424c
Fixes issue 32392: Wrong value in qtyreserved column of m_storage_pending in sales quotation.

When the "Create Order process" was launched from a Sales Quotation that generates pending storage, the ordered quantity in the M_STORAGE_PENDING was the double than the original for a recently created product. It was caused because a double call of the M_UPDATE_STORAGE_PENDING PL. Inside the C_ORDER_POST PL (it creates the entry inside the M_STORAGE_PENDING with the quantity reserved), and then the lines were processed again, the M_UPDATE_STORAGE_PENDING was called again and it updates the previously created entry increasing the quantity reserved once more time.
The process is working as expected now.
src/org/openbravo/erpCommon/ad_process/ConvertQuotationIntoOrder.java
--- a/src/org/openbravo/erpCommon/ad_process/ConvertQuotationIntoOrder.java	Mon Apr 04 11:52:47 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/ConvertQuotationIntoOrder.java	Mon Mar 28 12:44:57 2016 -0400
@@ -263,26 +263,6 @@
       OBDal.getInstance().refresh(objCloneOrder);
       OBDal.getInstance().refresh(objOrder);
 
-      try {
-        OBContext.setAdminMode(true);
-        for (OrderLine orderLine : objCloneOrder.getOrderLineList()) {
-          if (("I".equals(orderLine.getProduct().getProductType()))
-              && (orderLine.getProduct().isStocked())) {
-            if (orderLine.isDirectShipment()) {
-              update = ((Zero.subtract(orderLine.getReservedQuantity())).subtract(orderLine
-                  .getDeliveredQuantity())) != Zero;
-            } else {
-              update = ((orderLine.getOrderedQuantity().subtract(orderLine.getReservedQuantity()))
-                  .subtract(orderLine.getDeliveredQuantity())) != Zero;
-            }
-            if (update) {
-              callUpdateStoragePending(objCloneOrder, orderLine);
-            }
-          }
-        }
-      } finally {
-        OBContext.restorePreviousMode();
-      }
       OBDal.getInstance().commitAndClose();
       OBError result = OBErrorBuilder.buildMessage(null, "success", "@SalesOrderDocumentno@ "
           + objCloneOrder.getDocumentNo() + " @beenCreated@");