Fixes issue 30556: Available stock check not correct in M_INOUT_POST
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Thu, 20 Aug 2015 10:41:31 +0200
changeset 27384 f8dc8ea21e39
parent 27383 a2790dd1c422
child 27385 1d9e795478ba
Fixes issue 30556: Available stock check not correct in M_INOUT_POST

M_InOut organization was sent when calling M_Check_Stock in M_INOUT_POST function instead of M_InOutLine Locator's organization
src-db/database/model/functions/M_INOUT_POST.xml
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Wed Aug 12 10:53:32 2015 +0200
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Thu Aug 20 10:41:31 2015 +0200
@@ -73,6 +73,7 @@
     --
     v_Result NUMBER:=1;
     v_AD_Org_ID VARCHAR2(32);
+    v_Locator_Org_ID VARCHAR2(32);
     v_Warehouse_Org VARCHAR2(32);
     v_AD_Client_ID VARCHAR2(32);
     v_NextNo VARCHAR2(32);
@@ -798,7 +799,8 @@
               END IF;
             END IF;
             IF(Cur_InOutLine.M_Product_ID IS NOT NULL AND v_IsStocked=1) THEN
-              M_Check_Stock(Cur_InOutLine.M_Product_ID, v_AD_Client_ID, v_AD_Org_ID, v_Result, v_Message) ;
+              SELECT AD_Org_ID INTO v_Locator_Org_ID FROM M_Locator L WHERE M_Locator_ID = Cur_InOutLine.M_Locator_ID;
+              M_Check_Stock(Cur_InOutLine.M_Product_ID, v_AD_Client_ID, v_Locator_Org_ID, v_Result, v_Message) ;
               IF v_Result=0 THEN
                 SELECT name INTO v_ProductName FROM M_Product WHERE M_Product_id = Cur_InOutLine.M_Product_ID;
 			    RAISE_APPLICATION_ERROR(-20000, v_Message||' '||'@line@'||' '||Cur_InOutLine.line||', '||'@Product@'||' '||v_ProductName) ;