[Characteristics]Avoid using generic products in procedures.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Tue, 25 Jun 2013 18:20:57 +0200
changeset 20940 3348ce170fc7
parent 20939 b79dcb1948bc
child 20941 d6e6844d8dda
[Characteristics]Avoid using generic products in procedures.
src-db/database/model/functions/C_COMMISSION_PROCESS.xml
src-db/database/model/functions/C_GENERATEPOFROMPROJECT.xml
src-db/database/model/functions/C_GENERATESOFROMPROJECT.xml
src-db/database/model/functions/C_GENERATESOFROMPROJECTORDER.xml
src-db/database/model/functions/C_GENERATESOFROMPROJECTPHASE.xml
src-db/database/model/functions/C_INVOICE_POST.xml
src-db/database/model/functions/C_ORDER_POST1.xml
src-db/database/model/functions/MA_WORKEFFORT_VALIDATE.xml
src-db/database/model/functions/M_INOUT_POST.xml
src-db/database/model/functions/M_INTERNAL_CONSUMPTION_POST1.xml
src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml
src-db/database/model/functions/M_INVENTORY_POST.xml
src-db/database/model/functions/M_MOVEMENT_POST.xml
src-db/database/model/functions/M_PRODUCTION_RUN.xml
src-db/database/model/functions/M_REQUISITION_POST.xml
src-db/database/model/functions/M_RESERVATION_POST.xml
src-db/database/model/tables/M_PRODUCT.xml
src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/model/functions/C_COMMISSION_PROCESS.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/C_COMMISSION_PROCESS.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -46,6 +46,8 @@
     v_C_CommissionRun_ID VARCHAR2(32) ;
     v_NextNo VARCHAR2(32) ;
     v_DocumentNo VARCHAR(40) ;
+    v_isgeneric CHAR(1);
+    v_productname M_Product.Name%TYPE;
   BEGIN
     --  Update AD_PInstance
     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
@@ -80,16 +82,18 @@
     * Create Header + Determine DATE Range
     */
     v_ResultStr:='ReadingRecord';
-    SELECT AD_Client_ID,
-      AD_Org_ID,
-      Name,
-      FrequencyType,
-      DocBasisType,
-      ListDetails,
-      C_BPartner_ID, 
-      BasisStatus, 
-      BasisAmt, 
-      iscascade
+    SELECT c.AD_Client_ID,
+      c.AD_Org_ID,
+      c.Name,
+      c.FrequencyType,
+      c.DocBasisType,
+      c.ListDetails,
+      c.C_BPartner_ID, 
+      c.BasisStatus, 
+      c.BasisAmt, 
+      c.iscascade,
+      COALESCE(p.isgeneric, 'N'),
+      p.name
     INTO v_AD_Client_ID,
       v_AD_Org_ID,
       v_Name,
@@ -99,10 +103,17 @@
       v_SalesRep_ID, 
       v_BasisStatus, 
       v_BasisAmt, 
-      v_isCascade
-    FROM C_Commission
+      v_isCascade,
+      v_isgeneric,
+      v_productname
+    FROM C_Commission c
+        LEFT JOIN m_product p ON c.m_product_id = p.m_product_id
     WHERE C_Commission_ID=v_Record_ID;
     --
+    IF (v_isgeneric = 'Y') THEN
+      RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+    END IF;
+    
     SELECT ISO_Code
     INTO v_Currency
     FROM C_Currency cur,
--- a/src-db/database/model/functions/C_GENERATEPOFROMPROJECT.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/C_GENERATEPOFROMPROJECT.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -31,6 +31,8 @@
     v_C_OrderLine_ID VARCHAR2(32);
     v_C_DOCTYPE_ID VARCHAR2(32);
     v_DocumentNo NVARCHAR2(30) ;
+    v_isgeneric CHAR(1);
+    v_productname M_Product.Name%TYPE;
   BEGIN
     --  Update AD_PInstance
     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
@@ -207,6 +209,12 @@
             ORDER BY SEQNO ASC
             )
           LOOP
+            SELECT COALESCE(isgeneric, 'N'), name INTO v_isgeneric, v_productname
+            FROM m_product
+            WHERE m_product_id = cur_solines.m_product_id;
+            IF (v_isgeneric = 'Y') THEN
+              RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+            END IF;
 
             -- Take StdPrice, PriceList and PriceLimit from Price List Version
             SELECT COUNT(*)
--- a/src-db/database/model/functions/C_GENERATESOFROMPROJECT.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/C_GENERATESOFROMPROJECT.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -32,6 +32,8 @@
     v_C_OrderLine_ID VARCHAR2(32);
     v_C_DOCTYPE_ID VARCHAR2(32);
     v_DocumentNo NVARCHAR2(30) ;
+    v_isgeneric CHAR(1);
+    v_productname M_Product.Name%TYPE;
   BEGIN
     --  Update AD_PInstance
     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
@@ -181,6 +183,12 @@
             ORDER BY SEQNO ASC
             )
           LOOP
+            SELECT COALESCE(isgeneric, 'N'), name INTO v_isgeneric, v_productname
+            FROM m_product
+            WHERE m_product_id = cur_solines.m_product_id;
+            IF (v_isgeneric = 'Y') THEN
+              RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+            END IF;
 
             -- Take StdPrice, PriceList and PriceLimit from Price List Version
             SELECT COUNT(*)
--- a/src-db/database/model/functions/C_GENERATESOFROMPROJECTORDER.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/C_GENERATESOFROMPROJECTORDER.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -33,6 +33,8 @@
     v_C_OrderLine_ID VARCHAR2(32);
     v_C_DOCTYPE_ID VARCHAR2(32);
     v_DocumentNo VARCHAR(40);
+    v_isgeneric CHAR(1);
+    v_productname M_Product.Name%TYPE;
   BEGIN
     --  Update AD_PInstance
     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
@@ -125,6 +127,15 @@
           FOR SOLINES IN
             (SELECT * FROM C_PROJECTLINE WHERE C_PROJECT_ID=v_Record_ID)
           LOOP
+            IF (solines.m_product_id IS NOT NULL) THEN
+              SELECT COALESCE(isgeneric, 'N'), name INTO v_isgeneric, v_productname
+              FROM m_product
+              WHERE m_product_id = solines.m_product_id;
+              IF (v_isgeneric = 'Y') THEN
+                RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+              END IF;
+            END IF;
+
             IF(SOLINES.M_PRODUCT_ID IS NOT NULL AND Cur_SO.M_PRICELIST_VERSION_ID IS NOT NULL) THEN
               v_ResultStr:='SOLINES1 - SO.M_PRICELIST_VERSION_ID - ' || Cur_SO.M_PRICELIST_VERSION_ID || ' - ' || SOLINES.M_PRODUCT_ID;
               SELECT COUNT(p.C_UOM_ID)
--- a/src-db/database/model/functions/C_GENERATESOFROMPROJECTPHASE.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/C_GENERATESOFROMPROJECTPHASE.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -191,14 +191,16 @@
             -- And if no price is defined in the price list, price is set to 0.
           FOR Cur_SOLINES IN
             (
-            SELECT 'phase' AS PROV, pp.SEQNO, pp.NAME AS LINE_NAME, pp.DESCRIPTION, pr.NAME AS PRODUCT_NAME, pp.M_PRODUCT_ID, pp.QTY, pp.PRICEACTUAL
+            SELECT 'phase' AS PROV, pp.SEQNO, pp.NAME AS LINE_NAME, pp.DESCRIPTION, pr.NAME AS PRODUCT_NAME, pp.M_PRODUCT_ID, pp.QTY, pp.PRICEACTUAL,
+              COALESCE(pr.isgeneric, 'N') as isgeneric
             FROM C_PROJECTPHASE pp, M_PRODUCT pr
             WHERE pp.C_PROJECTPHASE_ID = v_Record_ID
               AND pp.M_PRODUCT_ID = pr.M_PRODUCT_ID
               AND pp.M_Product_ID IS NOT NULL
               AND pp.IsActive = 'Y'
             UNION
-            SELECT 'task' as PROV, pt.SEQNO, pt.NAME AS LINE_NAME, pt.DESCRIPTION, pr.NAME AS PRODUCT_NAME, pt.M_PRODUCT_ID, pt.QTY, pt.PRICEACTUAL
+            SELECT 'task' as PROV, pt.SEQNO, pt.NAME AS LINE_NAME, pt.DESCRIPTION, pr.NAME AS PRODUCT_NAME, pt.M_PRODUCT_ID, pt.QTY, pt.PRICEACTUAL,
+              COALESCE(pr.isgeneric, 'N') as isgeneric
             FROM C_PROJECTTASK pt, C_PROJECTPHASE pp, M_PRODUCT pr
             WHERE pp.C_PROJECTPHASE_ID = v_Record_ID
               AND pp.C_PROJECTPHASE_ID = pt.C_PROJECTPHASE_ID
@@ -208,6 +210,9 @@
             ORDER BY PROV ASC, SEQNO ASC
             )
           LOOP
+            IF (cur_solines.isgeneric = 'Y') THEN
+              RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || cur_solines.product_name);
+            END IF;
 
             -- Take StdPrice, PriceList and PriceLimit from Price List Version
             SELECT COUNT(*)
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -169,7 +169,7 @@
   v_bpartner_blocked VARCHAR2(1):='N';
   v_invoiceBlocking VARCHAR2(1):='N';
   v_bpartner_name c_bpartner.name%TYPE;
-
+  v_productname m_product.name%TYPE;
     
 BEGIN
   IF (p_PInstance_ID IS NOT NULL) THEN
@@ -294,6 +294,14 @@
     IF (v_count=0) THEN
       RAISE_APPLICATION_ERROR(-20000, '@InvoicesNeedLines@');
     END IF;
+    SELECT count(*), max(p.name) INTO v_count, v_productname
+    FROM c_invoiceline il JOIN m_product p ON il.m_product_id = p.m_product_id
+    WHERE COALESCE(p.isgeneric, 'N') = 'Y'
+      AND il.c_invoice_id = v_record_id;
+    IF (v_count > 0) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+    END IF;
+
     /*
      * Avoids repeating the same documentno for the same organization tree within the same fiscal year
      */
--- a/src-db/database/model/functions/C_ORDER_POST1.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -117,6 +117,7 @@
   v_bpartner_blocked VARCHAR2(1):='N';
   v_orderBlocking VARCHAR2(1):='N';
   v_bpartner_name c_bpartner.name%TYPE;
+  v_productname m_product.name%TYPE;
 
   BEGIN
     IF (p_PInstance_ID IS NOT NULL) THEN
@@ -210,6 +211,14 @@
     SELECT name INTO v_Org_Name FROM AD_ORG WHERE ad_org_id = v_Org_ID;
     DBMS_OUTPUT.PUT_LINE('DocAction=' || v_DocAction || ', DocStatus=' || v_DocStatus || ', DocType_ID=' || v_DocType_ID || ', DocTypeTarget_ID=' || v_DocTypeTarget_ID || ', DocSubTypeSO=' || v_DocSubTypeSO) ;
 
+    SELECT count(*), max(p.name) INTO v_aux, v_productname
+    FROM c_orderline ol JOIN m_product p ON ol.m_product_id = p.m_product_id
+    WHERE ol.c_order_id = v_record_id
+      AND COALESCE(p.isgeneric, 'N') = 'Y';
+    IF (v_aux > 0) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+    END IF;
+
     /** 
     * Quotations
     */
--- a/src-db/database/model/functions/MA_WORKEFFORT_VALIDATE.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/MA_WORKEFFORT_VALIDATE.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -68,6 +68,7 @@
     v_prodline NUMBER;
     v_line NUMBER;
     v_AD_Pinstance_ID VARCHAR2(32);
+    v_productname m_product.name%TYPE;
   BEGIN
     -- Process Parameters
     IF(p_PInstance_ID IS NOT NULL) THEN
@@ -104,6 +105,16 @@
       v_Message:='@WorkEffortValidated@';
       RAISE_APPLICATION_ERROR(-20000, v_Message);
     END IF;
+    SELECT count(*), max(p.name) INTO v_count, v_productname
+    FROM m_productionplan pp
+        JOIN m_productionline pl ON pp.m_productionplan_id = pl.m_productionplan_id
+        JOIN m_product p ON p.m_product_id = pl.m_product_id
+    WHERE pp.m_production_id = v_record_id
+      AND COALESCE(p.isgeneric, 'N') = 'Y';
+    IF (v_count > 0) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+    END IF;
+    
     IF(NOT FINISH_PROCESS) THEN
       -- Check that there are some parts of the job and that theay are processed
       
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -262,6 +262,15 @@
         RAISE_APPLICATION_ERROR(-20000, '@ReturnInOutNegativeQty@');
       END IF;
     END IF;
+      SELECT count(*), max(p.name)
+        INTO v_count, v_productname
+      FROM m_inoutline il JOIN m_product p ON il.m_product_id = p.m_product_id
+      WHERE il.m_inout_id = v_record_id
+        AND COALESCE(p.isgeneric, 'N') = 'Y';
+      IF (v_count > 0) THEN
+        RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+      END IF;
+      
         -- Process Shipments
       SELECT COUNT(*) INTO v_Aux
       FROM M_InOutLine
--- a/src-db/database/model/functions/M_INTERNAL_CONSUMPTION_POST1.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/M_INTERNAL_CONSUMPTION_POST1.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -47,6 +47,7 @@
   v_action VARCHAR2(60):='CO';
   v_status M_Internal_Consumption.status%TYPE;
   v_name M_Internal_Consumption.name%TYPE;
+  v_productname m_product.name%TYPE;
 BEGIN
   --  Update AD_PInstance
   IF (pinstance_id IS NOT NULL) THEN
@@ -113,6 +114,15 @@
   IF (v_Count = 0) THEN
     RAISE_APPLICATION_ERROR(-20000, '@InternalConsuptionNoLines@') ;
   END IF;
+
+  SELECT count(*), max(p.name)
+    INTO v_count, v_productname
+  FROM m_internal_consumptionline icl JOIN m_product p ON icl.m_product_id = p.m_product_id
+  WHERE icl.m_internal_consumption_id = record_id
+    AND COALESCE(p.isgeneric, 'N') = 'Y';
+  IF (v_count > 0) THEN
+    RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+  END IF;
   
   IF (v_action IN ('CO')) THEN
     /**
--- a/src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -165,6 +165,7 @@
           FROM M_Product p
           WHERE p.AD_Client_ID=v_Client_ID
             AND IsStocked='Y'
+            AND COALESCE(p.isgeneric, 'N') = 'N'
             AND NOT EXISTS
             (SELECT *
             FROM M_Storage_Detail s
@@ -240,6 +241,7 @@
 		 AND COALESCE(QTYORDERONHAND,0) = 0
 		 AND PREQTYONHAND=0
 		 AND COALESCE(PREQTYORDERONHAND,0) = 0) OR v_QtyRange = '=')
+        AND COALESCE(p.isgeneric, 'N') = 'N'
       ORDER BY s.M_Locator_ID,
         p.Value,
         s.Created
--- a/src-db/database/model/functions/M_INVENTORY_POST.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/M_INVENTORY_POST.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -63,6 +63,7 @@
     END_PROCESS BOOLEAN:=false;
     END_PROCESSING BOOLEAN:=false;
     rowcount NUMBER;
+    v_productname m_product.name%TYPE;
   BEGIN
     --  Update AD_PInstance
     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing') ;
@@ -132,6 +133,14 @@
     IF v_Count<>0 THEN
       RAISE_APPLICATION_ERROR(-20000, '@Inline@'||' '||v_line||' '||'@productWithoutAttributeSet@') ;
     END IF;
+    SELECT count(*), max(p.name)
+      INTO v_count, v_productname
+    FROM m_inventoryline il JOIN m_product p ON il.m_product_id = p.m_product_id
+    WHERE il.m_inventory_id = v_record_id
+      AND COALESCE(p.isgeneric, 'N') = 'Y';
+    IF (v_count > 0) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+    END IF;
   END IF;--PROCESS_ERROR
   IF(NOT PROCESS_ERROR AND NOT END_PROCESS AND NOT END_PROCESSING) THEN
     -- Check for products in multiple lines
--- a/src-db/database/model/functions/M_MOVEMENT_POST.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/M_MOVEMENT_POST.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -55,6 +55,7 @@
     v_isacctle AD_OrgType.IsAcctLegalEntity%TYPE;
     v_org_bule_id AD_Org.AD_Org_ID%TYPE;
     END_PROCESS BOOLEAN:=false;
+    v_productname m_product.name%TYPE;
   BEGIN
     --  Update AD_PInstance
     DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || PInstance_ID) ;
@@ -117,6 +118,14 @@
       IF v_Count<>0 THEN
        RAISE_APPLICATION_ERROR(-20000, '@Inline@'||' '||v_line||' '||'@productWithoutAttributeSet@') ;
       END IF;
+      SELECT count(*), max(p.name)
+        INTO v_count, v_productname
+      FROM m_movementline ml JOIN m_product p ON ml.m_product_id = p.m_product_id
+      WHERE ml.m_movement_id = v_record_id
+        AND COALESCE(p.isgeneric, 'N') = 'Y';
+      IF (v_count > 0) THEN
+        RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+      END IF;
     END IF;--END_PROCESS
     IF(NOT END_PROCESS) THEN
       -- Start Processing ------------------------------------------------------
--- a/src-db/database/model/functions/M_PRODUCTION_RUN.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/M_PRODUCTION_RUN.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -59,7 +59,7 @@
   v_Line NUMBER;
   v_Count NUMBER;
   p_User VARCHAR2(32);
-  v_Product_Name VARCHAR2(2000):='';
+  v_Product_Name m_product.name%TYPE;
   -- Stocked BOMs
   -- Proposed stock from given warehouse is priorized.
   CURSOR CUR_STOCK (v_ad_pinstance_id VARCHAR) IS
@@ -457,6 +457,16 @@
       v_Message:='@Product@'||' "' ||v_Product_Name ||'" ' || '@ProductWithoutAttributeSet@';
       RAISE_APPLICATION_ERROR(-20000, v_Message);
     END IF;
+    SELECT count(*), max(p.name) INTO v_count, v_product_name
+    FROM m_productionplan pp
+        JOIN m_productionline pl ON pp.m_productionplan_id = pl.m_productionplan_id
+        JOIN m_product p ON pl.m_product_id = p.m_product_id
+    WHERE pp.m_production_id = v_record_id
+      AND COALESCE(p.isgeneric, 'N') = 'Y';
+    IF (v_count > 0) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_product_Name);
+    END IF;
+
     -- All Production Lines
     FOR CUR_PL_Post IN (
         SELECT pl.M_ProductionLine_ID, pl.AD_Client_ID, pl.AD_Org_ID, p.MovementDate,
--- a/src-db/database/model/functions/M_REQUISITION_POST.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/M_REQUISITION_POST.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -33,6 +33,7 @@
   v_bpartner_blocked VARCHAR2(1):='N';
   v_inOutBlocking VARCHAR2(1):='N';
   v_bpartner_name c_bpartner.name%TYPE;
+  v_productname m_product.name%TYPE;
 
   --  Parameter
   TYPE RECORD IS REF CURSOR;
@@ -61,6 +62,7 @@
     SELECT DocAction, DocStatus , c_bpartner_id INTO v_DocAction, v_DocStatus, v_bpartner
     FROM M_REQUISITION
     WHERE M_REquisition_ID = v_Record_ID;
+    
     IF (v_DocAction = 'CO' AND v_bpartner IS NOT NULL) THEN
       SELECT  vendor_blocking , po_order_blocking, name  
       INTO v_bpartner_blocked, v_inOutBlocking, v_bpartner_name
@@ -105,6 +107,14 @@
       END IF;
     END IF;
 
+    SELECT count(*), max(p.name) INTO v_aux, v_productname
+    FROM m_requisitionline rl JOIN m_product p ON rl.m_product_id = p.m_product_id
+    WHERE rl.m_requisition_id = v_record_id
+      AND COALESCE(p.isgeneric, 'N') = 'Y';
+    IF (v_aux > 0) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+    END IF;
+
     /**
     * Order Closed, Voided or Reversed - No action possible
     */
--- a/src-db/database/model/functions/M_RESERVATION_POST.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/functions/M_RESERVATION_POST.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -46,6 +46,7 @@
   v_count           NUMBER;
   v_quantity        NUMBER;
   v_reservedqty     NUMBER;
+  v_productname     m_product.name%TYPE;
 
 TYPE RECORD IS REF CURSOR;
   Cur_Parameter RECORD;
@@ -86,6 +87,14 @@
   FROM m_reservation
   WHERE m_reservation_id = v_reservation_id;
   
+  SELECT count(*), max(p.name) INTO v_count, v_productname
+  FROM m_product p 
+  WHERE p.m_product_id = v_product_id
+    AND COALESCE(p.isgeneric, 'N') = 'Y';
+  IF (v_count > 0) THEN
+    RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
+  END IF;
+  
   IF (v_resaction = 'PR') THEN
   /*
     Reservation Complete Process
--- a/src-db/database/model/tables/M_PRODUCT.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/model/tables/M_PRODUCT.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -402,6 +402,9 @@
       <foreign-key foreignTable="MA_PROCESSPLAN" name="MA_PROCESSPLAN_MPRODUCT">
         <reference local="MA_PROCESSPLAN_ID" foreign="MA_PROCESSPLAN_ID"/>
       </foreign-key>
+      <index name="M_PRODUC_ISGENERID_IDX" unique="false">
+        <index-column name="ISGENERIC"/>
+      </index>
       <index name="M_PRODUCT_BPARTNER" unique="false">
         <index-column name="C_BPARTNER_ID"/>
       </index>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Jun 25 13:08:10 2013 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Jun 25 18:20:57 2013 +0200
@@ -22108,6 +22108,18 @@
 <!--B2DA469610FB457699D8B70BEDE009E4-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--B2DA469610FB457699D8B70BEDE009E4--></AD_MESSAGE>
 
+<!--B2E2BD179E374B09A39DCB5A3A301F0B--><AD_MESSAGE>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B-->  <AD_MESSAGE_ID><![CDATA[B2E2BD179E374B09A39DCB5A3A301F0B]]></AD_MESSAGE_ID>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B-->  <VALUE><![CDATA[CannotUseGenericProduct]]></VALUE>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B-->  <MSGTEXT><![CDATA[It is not possible to use generic products in the document.]]></MSGTEXT>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--B2E2BD179E374B09A39DCB5A3A301F0B--></AD_MESSAGE>
+
 <!--B39063570565473E81C41FC76BE18078--><AD_MESSAGE>
 <!--B39063570565473E81C41FC76BE18078-->  <AD_MESSAGE_ID><![CDATA[B39063570565473E81C41FC76BE18078]]></AD_MESSAGE_ID>
 <!--B39063570565473E81C41FC76BE18078-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>