Fixes Issue 24812: Wrong warehouse could be selected in orders,shipments
authorPandeeswari Ramakrishnan <pandeeswari.ramakrishnan@openbravo.com>
Thu, 26 Sep 2013 12:06:20 +0530
changeset 21353 408b26ad5754
parent 21352 a0f38c176c97
child 21354 d463b46ad1e6
Fixes Issue 24812: Wrong warehouse could be selected in orders,shipments
src-db/database/model/functions/C_ORDER_POST1.xml
src-db/database/model/functions/M_INOUT_POST.xml
src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/model/functions/C_ORDER_POST1.xml	Tue Oct 01 12:15:58 2013 +0530
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml	Thu Sep 26 12:06:20 2013 +0530
@@ -197,6 +197,17 @@
     FROM C_DOCTYPE
     WHERE C_DocType_ID=v_DocTypetarget_ID;
 
+    --Check whether warehouse belongs to the organization.
+    SELECT count(AD_ORG_ID)
+    INTO v_count
+    FROM AD_Org_Warehouse
+    WHERE M_Warehouse_ID=v_M_Warehouse_ID
+    AND AD_Org_ID = v_Org_ID;
+
+    IF v_count = 0 THEN
+    RAISE_APPLICATION_ERROR(-20000,'@WrongWarehouse@') ;
+    END IF;
+
     SELECT CASE WHEN (m.ISSOTRX='Y') THEN customer_blocking  ELSE vendor_blocking END ,  
     CASE WHEN (m.ISSOTRX='Y') THEN so_order_blocking ELSE po_order_blocking  END, name, DocAction
       INTO v_bpartner_blocked, v_orderBlocking, v_bpartner_name, v_DocAction
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Tue Oct 01 12:15:58 2013 +0530
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Thu Sep 26 12:06:20 2013 +0530
@@ -94,6 +94,7 @@
     v_Aux NUMBER;
     v_ProductName M_Product.name%TYPE;
     v_reservation_id    VARCHAR2(32);
+    v_M_Warehouse_ID    VARCHAR2(32);
     v_voidmovementdate M_Inout.MovementDate%TYPE;
     v_voiddate_acct M_Inout.DateAcct%TYPE;
     v_bpartner_blocked VARCHAR2(1):='N';
@@ -147,8 +148,8 @@
   BEGIN --BODY
   	IF(NOT FINISH_PROCESS) THEN
   	  v_PUser:=v_User;
-      SELECT io.AD_Client_ID, io.AD_Org_ID, io.CreatedBy, io.C_DocType_ID, io.DateAcct, dt.isreturn
-        INTO v_AD_Client_ID, v_AD_Org_ID, v_User, v_DocType_ID, v_DateAcct, v_isreturndoctype
+      SELECT io.AD_Client_ID, io.AD_Org_ID, io.CreatedBy, io.C_DocType_ID, io.DateAcct, dt.isreturn, io.m_warehouse_id
+        INTO v_AD_Client_ID, v_AD_Org_ID, v_User, v_DocType_ID, v_DateAcct, v_isreturndoctype, v_M_Warehouse_ID
         FROM M_InOut io JOIN c_doctype dt ON io.c_doctype_id = dt.c_doctype_id
         WHERE io.M_InOut_ID=v_Record_ID;
         IF(v_PUser IS NOT NULL) THEN
@@ -172,7 +173,18 @@
           RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgBpartnerInout@') ;
         END IF;
       END IF;
-      
+
+      --Check whether warehouse belongs to the organization.
+      SELECT count(AD_ORG_ID)
+      INTO v_count
+      FROM AD_Org_Warehouse
+      WHERE M_Warehouse_ID=v_M_Warehouse_ID
+      AND AD_Org_ID = v_AD_Org_ID;
+
+      IF v_count = 0 THEN
+        RAISE_APPLICATION_ERROR(-20000,'@WrongWarehouse@');
+      END IF;
+
       SELECT CASE WHEN (m.ISSOTRX='Y') THEN customer_blocking ELSE vendor_blocking END, CASE WHEN (m.ISSOTRX='Y') 
       THEN so_goods_blocking ELSE po_goods_blocking END, name, DocAction
       INTO v_bpartner_blocked, v_goods_blocked, v_bpartner_name, v_DocAction
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Oct 01 12:15:58 2013 +0530
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Thu Sep 26 12:06:20 2013 +0530
@@ -17206,6 +17206,18 @@
 <!--24B4AED8FE3542C2933B4EA37DF641C5-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--24B4AED8FE3542C2933B4EA37DF641C5--></AD_MESSAGE>
 
+<!--24D4D0CD283B4C5BB2A369893ED8132D--><AD_MESSAGE>
+<!--24D4D0CD283B4C5BB2A369893ED8132D-->  <AD_MESSAGE_ID><![CDATA[24D4D0CD283B4C5BB2A369893ED8132D]]></AD_MESSAGE_ID>
+<!--24D4D0CD283B4C5BB2A369893ED8132D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--24D4D0CD283B4C5BB2A369893ED8132D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--24D4D0CD283B4C5BB2A369893ED8132D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--24D4D0CD283B4C5BB2A369893ED8132D-->  <VALUE><![CDATA[WrongWarehouse]]></VALUE>
+<!--24D4D0CD283B4C5BB2A369893ED8132D-->  <MSGTEXT><![CDATA[The Warehouse of the document does not belong to the selected Organization]]></MSGTEXT>
+<!--24D4D0CD283B4C5BB2A369893ED8132D-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--24D4D0CD283B4C5BB2A369893ED8132D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--24D4D0CD283B4C5BB2A369893ED8132D-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--24D4D0CD283B4C5BB2A369893ED8132D--></AD_MESSAGE>
+
 <!--24D75AD6BD814259BFF03E41B49EDFD3--><AD_MESSAGE>
 <!--24D75AD6BD814259BFF03E41B49EDFD3-->  <AD_MESSAGE_ID><![CDATA[24D75AD6BD814259BFF03E41B49EDFD3]]></AD_MESSAGE_ID>
 <!--24D75AD6BD814259BFF03E41B49EDFD3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>