Fixes Issue 30754:Stock of inactive products can be increased.
authorAtul Gaware <atul.gaware@openbravo.com>
Mon, 28 Sep 2015 19:19:54 +0530
changeset 27706 c10451d08a85
parent 27705 522b10556e44
child 27707 29524c0b6c24
Fixes Issue 30754:Stock of inactive products can be increased.

Before processing Goods Receipt, Goods Shipment with -ve lines, BOM Production
and Work effort transaction line product active flag is checked.
src-db/database/model/functions/MA_WORKEFFORT_VALIDATE.xml
src-db/database/model/functions/M_INOUT_POST.xml
src-db/database/model/functions/M_PRODUCTION_RUN.xml
src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/model/functions/MA_WORKEFFORT_VALIDATE.xml	Thu Oct 01 14:57:25 2015 +0200
+++ b/src-db/database/model/functions/MA_WORKEFFORT_VALIDATE.xml	Mon Sep 28 19:19:54 2015 +0530
@@ -308,6 +308,38 @@
         FINISH_PROCESS:=TRUE;
       END IF;
     END IF;
+    IF(NOT FINISH_PROCESS) THEN
+      DECLARE
+        v_Message_ProductionRun VARCHAR(2000) :='';
+        v_Message_ProductLine VARCHAR(2000) :='';
+        BEGIN
+          FOR CUR_ProductionPlan IN
+            (SELECT pp.Line, pp.M_PRODUCTIONPLAN_ID
+            FROM M_PRODUCTION p, M_PRODUCTIONPLAN pp
+            WHERE p.M_Production_ID=pp.M_Production_ID
+            AND pp.M_Production_ID=v_Record_ID
+            ORDER BY pp.Line)
+          LOOP
+            FOR CUR_PL_Post IN
+              (SELECT pl.Line
+              FROM M_PRODUCTIONLINE pl, M_PRODUCT pr
+              WHERE Cur_ProductionPlan.M_ProductionPlan_ID=pl.M_ProductionPlan_ID
+              AND pl.M_PRODUCT_ID=pr.M_PRODUCT_ID
+              AND pr.ISACTIVE='N'
+              ORDER BY pl.Line)
+            LOOP
+              v_Message_ProductLine:=v_Message_ProductLine||CUR_PL_Post.line||', ';
+            END LOOP;
+            IF(v_Message_ProductLine != '') THEN
+              v_Message_ProductionRun:=v_Message_ProductionRun||'@ProductionRunLine@'||Cur_ProductionPlan.line||' @ProductLine@'||v_Message_ProductLine;
+              v_Message_ProductLine:='';
+            END IF;
+          END LOOP;
+          IF v_Message_ProductionRun != '' THEN
+            RAISE_APPLICATION_ERROR(-20000, v_Message_ProductionRun||'@InActiveProducts@');
+          END IF;
+        END;
+    END IF;
     -- All Production Lines
     IF(NOT FINISH_PROCESS) THEN
       FOR CUR_PL_Post IN
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Thu Oct 01 14:57:25 2015 +0200
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Mon Sep 28 19:19:54 2015 +0530
@@ -231,6 +231,24 @@
              RAISE_APPLICATION_ERROR(-20000, '@Inline@ '||v_Message_Qty||' '||'@ProductNotNullAndMovementQtyZero@') ;
           END IF;
 	     End ;
+      DECLARE
+      v_Message_Inactive_Products VARCHAR(2000) :='';
+      BEGIN
+        FOR Cur_Lines IN (
+          SELECT IOL.line
+          FROM M_InOutLine IOL, M_PRODUCT P
+          WHERE IOL.M_INOUT_ID=v_Record_ID
+          AND P.M_PRODUCT_ID = IOL.M_PRODUCT_ID
+          AND IOL.M_PRODUCT_ID IS NOT NULL AND P.ISACTIVE='N'
+          ORDER BY IOL.line
+          )
+        LOOP
+          v_Message_Inactive_Products:=v_Message_Inactive_Products||Cur_Lines.line||', ';
+        END LOOP;
+        IF v_Message_Inactive_Products != '' THEN
+          RAISE_APPLICATION_ERROR(-20000, '@Inline@ '||v_Message_Inactive_Products||' '||'@InActiveProducts@') ;
+        END IF;
+      END;
       SELECT CASE WHEN COALESCE(instr(M_INOUT.Description,'*R*:'),0) = 0 THEN 'N' ELSE 'Y' END
             INTO v_IsReversedDoc
             FROM M_INOUT
--- a/src-db/database/model/functions/M_PRODUCTION_RUN.xml	Thu Oct 01 14:57:25 2015 +0200
+++ b/src-db/database/model/functions/M_PRODUCTION_RUN.xml	Mon Sep 28 19:19:54 2015 +0530
@@ -546,6 +546,37 @@
       v_Message:= '@ConsumedProductWithPostiveQty@' || ' @ReferProductionPlanLines@' || ': ' || v_Message;
       RAISE_APPLICATION_ERROR(-20000, v_Message);
     END IF;
+
+    DECLARE
+        v_Message_ProductionRun VARCHAR(2000) :='';
+        v_Message_ProductLine VARCHAR(2000) :='';
+        BEGIN
+          FOR CUR_ProductionPlan IN
+            (SELECT pp.Line, pp.M_PRODUCTIONPLAN_ID
+            FROM M_PRODUCTION p, M_PRODUCTIONPLAN pp
+            WHERE p.M_Production_ID=pp.M_Production_ID
+            AND pp.M_Production_ID=v_Record_ID
+            ORDER BY pp.Line)
+          LOOP
+            FOR CUR_PL_Post IN
+              (SELECT pl.Line
+              FROM M_PRODUCTIONLINE pl, M_PRODUCT pr
+              WHERE Cur_ProductionPlan.M_ProductionPlan_ID=pl.M_ProductionPlan_ID
+              AND pl.M_PRODUCT_ID=pr.M_PRODUCT_ID
+              AND pr.ISACTIVE='N'
+              ORDER BY pl.Line)
+            LOOP
+              v_Message_ProductLine:=v_Message_ProductLine||CUR_PL_Post.line||', ';
+            END LOOP;
+            IF(v_Message_ProductLine != '') THEN
+              v_Message_ProductionRun:=v_Message_ProductionRun||'@ProductionRunLine@'||Cur_ProductionPlan.line||' @ProductLine@'||v_Message_ProductLine;
+              v_Message_ProductLine:='';
+            END IF;
+          END LOOP;
+          IF v_Message_ProductionRun != '' THEN
+            RAISE_APPLICATION_ERROR(-20000, v_Message_ProductionRun||'@InActiveProducts@');
+          END IF;
+        END;
     
     SELECT count(*) INTO v_count
     FROM dual
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Thu Oct 01 14:57:25 2015 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Mon Sep 28 19:19:54 2015 +0530
@@ -16391,6 +16391,18 @@
 <!--11314163807C4401B2964F93256597EA-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--11314163807C4401B2964F93256597EA--></AD_MESSAGE>
 
+<!--113D2212643A4188A76F4E95C3FEB98A--><AD_MESSAGE>
+<!--113D2212643A4188A76F4E95C3FEB98A-->  <AD_MESSAGE_ID><![CDATA[113D2212643A4188A76F4E95C3FEB98A]]></AD_MESSAGE_ID>
+<!--113D2212643A4188A76F4E95C3FEB98A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--113D2212643A4188A76F4E95C3FEB98A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--113D2212643A4188A76F4E95C3FEB98A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--113D2212643A4188A76F4E95C3FEB98A-->  <VALUE><![CDATA[InActiveProducts]]></VALUE>
+<!--113D2212643A4188A76F4E95C3FEB98A-->  <MSGTEXT><![CDATA[Product used in transaction is inactive. ]]></MSGTEXT>
+<!--113D2212643A4188A76F4E95C3FEB98A-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--113D2212643A4188A76F4E95C3FEB98A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--113D2212643A4188A76F4E95C3FEB98A-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--113D2212643A4188A76F4E95C3FEB98A--></AD_MESSAGE>
+
 <!--11509F0E2D6E4D4A96518FECB69A5B8F--><AD_MESSAGE>
 <!--11509F0E2D6E4D4A96518FECB69A5B8F-->  <AD_MESSAGE_ID><![CDATA[11509F0E2D6E4D4A96518FECB69A5B8F]]></AD_MESSAGE_ID>
 <!--11509F0E2D6E4D4A96518FECB69A5B8F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -17327,6 +17339,18 @@
 <!--2280EA8FD12C41D49D861A4681AB4A17-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--2280EA8FD12C41D49D861A4681AB4A17--></AD_MESSAGE>
 
+<!--22B1A5A415954591ADDA0FA81E684E87--><AD_MESSAGE>
+<!--22B1A5A415954591ADDA0FA81E684E87-->  <AD_MESSAGE_ID><![CDATA[22B1A5A415954591ADDA0FA81E684E87]]></AD_MESSAGE_ID>
+<!--22B1A5A415954591ADDA0FA81E684E87-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--22B1A5A415954591ADDA0FA81E684E87-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--22B1A5A415954591ADDA0FA81E684E87-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--22B1A5A415954591ADDA0FA81E684E87-->  <VALUE><![CDATA[ProductionRunLine]]></VALUE>
+<!--22B1A5A415954591ADDA0FA81E684E87-->  <MSGTEXT><![CDATA[Production Run Line No. ]]></MSGTEXT>
+<!--22B1A5A415954591ADDA0FA81E684E87-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--22B1A5A415954591ADDA0FA81E684E87-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--22B1A5A415954591ADDA0FA81E684E87-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--22B1A5A415954591ADDA0FA81E684E87--></AD_MESSAGE>
+
 <!--22BAFF96A26542FF91EC98794CE1FD86--><AD_MESSAGE>
 <!--22BAFF96A26542FF91EC98794CE1FD86-->  <AD_MESSAGE_ID><![CDATA[22BAFF96A26542FF91EC98794CE1FD86]]></AD_MESSAGE_ID>
 <!--22BAFF96A26542FF91EC98794CE1FD86-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -21567,6 +21591,18 @@
 <!--8750F1DB1207450E8947C482FF43E029-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--8750F1DB1207450E8947C482FF43E029--></AD_MESSAGE>
 
+<!--87F4030110BF457ABC427FEA68750143--><AD_MESSAGE>
+<!--87F4030110BF457ABC427FEA68750143-->  <AD_MESSAGE_ID><![CDATA[87F4030110BF457ABC427FEA68750143]]></AD_MESSAGE_ID>
+<!--87F4030110BF457ABC427FEA68750143-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--87F4030110BF457ABC427FEA68750143-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--87F4030110BF457ABC427FEA68750143-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--87F4030110BF457ABC427FEA68750143-->  <VALUE><![CDATA[ProductLine]]></VALUE>
+<!--87F4030110BF457ABC427FEA68750143-->  <MSGTEXT><![CDATA[Product Line No. ]]></MSGTEXT>
+<!--87F4030110BF457ABC427FEA68750143-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--87F4030110BF457ABC427FEA68750143-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--87F4030110BF457ABC427FEA68750143-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--87F4030110BF457ABC427FEA68750143--></AD_MESSAGE>
+
 <!--88A1D0A0F67F49339B2639EA4E5F6B4B--><AD_MESSAGE>
 <!--88A1D0A0F67F49339B2639EA4E5F6B4B-->  <AD_MESSAGE_ID><![CDATA[88A1D0A0F67F49339B2639EA4E5F6B4B]]></AD_MESSAGE_ID>
 <!--88A1D0A0F67F49339B2639EA4E5F6B4B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>