Fixes Issue 31514. Refreshes reservation object before checking status.
authorDavid Miguelez <david.miguelez@openbravo.com>
Fri, 04 Dec 2015 11:57:05 +0100
changeset 28095 e32a6dfe59e6
parent 28093 e867bcaa1cc6
child 28096 9a9e6209c555
Fixes Issue 31514. Refreshes reservation object before checking status.
Also, call to Reservation_Post process is moved to the end of the fucntion,
after the lines have been modified.
src/org/openbravo/common/actionhandler/ManageReservationActionHandler.java
--- a/src/org/openbravo/common/actionhandler/ManageReservationActionHandler.java	Tue Dec 01 19:06:20 2015 +0100
+++ b/src/org/openbravo/common/actionhandler/ManageReservationActionHandler.java	Fri Dec 04 11:57:05 2015 +0100
@@ -76,17 +76,10 @@
         final OrderLine sol = OBDal.getInstance().get(OrderLine.class, strOrderLineId);
         reservation = ReservationUtils.getReservationFromOrder(sol);
 
+        OBDal.getInstance().refresh(reservation);
         processReservation = reservation.getRESStatus().equals("DR");
       }
-      if (processReservation) {
-        OBError result = ReservationUtils.processReserve(reservation, "PR");
-        if (result.getType().equals("Error")) {
-          JSONObject errorMessage = new JSONObject();
-          errorMessage.put("severity", result.getType().toLowerCase());
-          errorMessage.put("text", result.getMessage());
-          jsonRequest.put("message", errorMessage);
-        }
-      }
+
       if (reservation != null) {
         // FIXME: Replace with OBDao method when handler is merged with latest pi.
         // List<String> idList = OBDao.getIDListFromOBObject(reservation
@@ -96,6 +89,16 @@
           idList.add(resStock.getId());
         }
         manageReservedStockLines(jsonRequest, reservation, idList);
+
+        if (processReservation) {
+          OBError result = ReservationUtils.processReserve(reservation, "PR");
+          if (result.getType().equals("Error")) {
+            JSONObject errorMessage = new JSONObject();
+            errorMessage.put("severity", result.getType().toLowerCase());
+            errorMessage.put("text", result.getMessage());
+            jsonRequest.put("message", errorMessage);
+          }
+        }
       }
 
     } catch (Exception e) {