Fixes Issue 22665 : Wrong error when completing the shipment without lines
authorPandeeswari Ramakrishnan <pandeeswari.ramakrishnan@openbravo.com>
Thu, 03 Jan 2013 12:02:52 +0530
changeset 19202 dc915067d2ce
parent 19201 6eaa790b7470
child 19203 9011368fc0cf
Fixes Issue 22665 : Wrong error when completing the shipment without lines
src-db/database/model/functions/M_INOUT_POST.xml
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Wed Jan 02 18:34:15 2013 +0100
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Thu Jan 03 12:02:52 2013 +0530
@@ -227,15 +227,20 @@
       END IF;
     END IF;
         -- Process Shipments
-  
-      SELECT COUNT(*)
-        INTO v_Count
-      FROM M_INOUT IO, M_INOUTLINE IOL
-      WHERE IO.M_INOUT_ID = IOL.M_INOUT_ID
-        AND AD_ISORGINCLUDED(IOL.AD_Org_ID, IO.AD_Org_ID, IO.AD_Client_ID) <> -1
-        AND IO.M_INOUT_ID = v_Record_ID;
-      IF (v_Count=0) THEN
-        RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgLines@') ;
+      SELECT COUNT(*) INTO v_Aux
+      FROM M_InOutLine
+      WHERE M_InOut_ID = v_Record_ID;
+
+      IF v_Aux > 0 THEN  
+        SELECT COUNT(*)
+	INTO v_Count
+        FROM M_INOUT IO, M_INOUTLINE IOL
+        WHERE IO.M_INOUT_ID = IOL.M_INOUT_ID
+	AND AD_ISORGINCLUDED(IOL.AD_Org_ID, IO.AD_Org_ID, IO.AD_Client_ID) <> -1
+	AND IO.M_INOUT_ID = v_Record_ID;
+        IF (v_Count=0) THEN
+	  RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgLines@') ;
+        END IF;
       END IF;
       
       -- Check the header belongs to a organization where transactions are posible and ready to use
@@ -296,9 +301,7 @@
           IF(Cur_InOut.Processed='N' AND Cur_InOut.DocStatus='DR' AND Cur_InOut.DocAction='CO') THEN
             -- For all active shipment lines
             v_ResultStr:='HeaderLoop-1';
-            SELECT COUNT(*) INTO v_Aux
-        FROM M_InOutLine
-        WHERE M_InOut_ID = v_Record_ID;
+            
         IF v_Aux=0 THEN
         RAISE_APPLICATION_ERROR(-20000, '@ReceiptWithoutLines@');
         END IF;