details:   https://code.openbravo.com/erp/devel/pi/rev/7c5936cbf166
changeset: 32028:7c5936cbf166
user:      Armaignac <collazoandy4 <at> gmail.com>
date:      Mon May 01 23:52:02 2017 -0400
summary:   Fixes issue 35831: Cannot deactivate a product included in a RTV 
Shipment

The qtyreserved column of the m_storage_pending table is wrongly updated in the
Return To Vendor Shipment process because the M_UPDATE_STORAGE_PENDING call in
c_orderline2_trg trigger doesn't take into account if the order isSOTrx.

Now the M_UPDATE_STORAGE_PENDING call in the trigger check if the order isSOTrx
to set the correct value of qtyreserved arg.

details:   https://code.openbravo.com/erp/devel/pi/rev/d46184b8539b
changeset: 32029:d46184b8539b
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Thu May 04 14:44:04 2017 +0200
summary:   Related to issue 35831: Code review improvements

diffstat:

 src-db/database/model/triggers/C_ORDERLINE2_TRG.xml |  29 ++++++++++++--------
 1 files changed, 17 insertions(+), 12 deletions(-)

diffs (52 lines):

diff -r 990d615bbfd3 -r d46184b8539b 
src-db/database/model/triggers/C_ORDERLINE2_TRG.xml
--- a/src-db/database/model/triggers/C_ORDERLINE2_TRG.xml       Thu May 04 
10:42:22 2017 +0200
+++ b/src-db/database/model/triggers/C_ORDERLINE2_TRG.xml       Thu May 04 
14:44:04 2017 +0200
@@ -18,7 +18,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2001-2016 Openbravo SLU
+* All portions are Copyright (C) 2001-2017 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -43,23 +43,28 @@
   IF(UPDATING) THEN
     IF(:NEW.M_PRODUCT_ID IS NOT NULL) THEN
     v_ID:=:old.C_Order_ID;
-    SELECT DocStatus
-    INTO v_DocStatus
+    SELECT DocStatus, isSOTrx
+    INTO v_DocStatus, v_isSOTrx
     FROM c_Order
     WHERE c_order_id = v_ID;
       IF(v_DocStatus <> 'DR') THEN
         IF((COALESCE(:old.QtyDelivered, 0) <> COALESCE(:NEW.QtyDelivered, 0))) 
THEN
           -- Get ID
           v_ID:=:new.C_Order_ID;
-          v_QtyReserved:=-(:new.qtydelivered - :old.qtydelivered) ;
-          IF :old.qtydelivered=0 AND :new.qtydelivered=:new.qtyordered THEN
-            v_QtyOrderReserved:=-:new.QuantityOrder;
-          ELSIF :new.M_Product_UOM_ID IS NOT NULL THEN
-            SELECT c_uom_id
-            INTO v_UOM_ID
-            FROM m_product_uom
-            WHERE m_product_uom_id = :new.m_product_uom_id;
-            v_QtyOrderReserved:=C_Uom_Convert(v_QtyReserved, :new.C_UOM_ID, 
v_UOM_ID, 'Y') ;
+          IF (v_isSOTrx = 'Y') THEN
+            v_QtyReserved := -(:new.qtydelivered - :old.qtydelivered);
+            IF (:old.qtydelivered=0 AND :new.qtydelivered=:new.qtyordered) THEN
+              v_QtyOrderReserved := -:new.QuantityOrder;
+            ELSIF (:new.M_Product_UOM_ID IS NOT NULL) THEN
+              SELECT c_uom_id
+              INTO v_UOM_ID
+              FROM m_product_uom
+              WHERE m_product_uom_id = :new.m_product_uom_id;
+              v_QtyOrderReserved := C_Uom_Convert(v_QtyReserved, 
:new.C_UOM_ID, v_UOM_ID, 'Y');
+            END IF;
+          ELSE
+            v_QtyReserved := 0;
+            v_QtyOrderReserved := null;
           END IF;
           SELECT COUNT(*)
           INTO V_STOCKED

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to