Fixed issue 27026.Added missing indexes and sql improvement.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Mon, 04 Aug 2014 08:40:38 +0200
changeset 24152 bae6b944d95a
parent 24151 4f31d2d162f9
child 24153 9ca3a8d726f5
Fixed issue 27026.Added missing indexes and sql improvement.
src-db/database/model/functions/M_RESERVATION_POST.xml
src-db/database/model/tables/AD_ORG_WAREHOUSE.xml
src-db/database/model/tables/M_RESERVATION.xml
src-db/database/model/tables/M_STOCK_PROPOSED.xml
--- a/src-db/database/model/functions/M_RESERVATION_POST.xml	Fri Aug 01 11:48:12 2014 +0530
+++ b/src-db/database/model/functions/M_RESERVATION_POST.xml	Mon Aug 04 08:40:38 2014 +0200
@@ -25,7 +25,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2012-2013 Openbravo SLU
+* All portions are Copyright (C) 2012-2014 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -232,6 +232,8 @@
                       JOIN m_reservation r ON rs2.m_reservation_id = r.m_reservation_id
                   WHERE rs2.c_orderline_id IS NOT NULL
                     AND r.res_status NOT IN ('DR')
+                    AND r.m_product_id = v_product_id
+                    AND r.c_uom_id = v_uom_id
                   GROUP BY rs2.c_orderline_id
                 ) pre ON rs.c_orderline_id = pre.c_orderline_id
           WHERE rs.m_reservation_id = v_reservation_id
--- a/src-db/database/model/tables/AD_ORG_WAREHOUSE.xml	Fri Aug 01 11:48:12 2014 +0530
+++ b/src-db/database/model/tables/AD_ORG_WAREHOUSE.xml	Mon Aug 04 08:40:38 2014 +0200
@@ -53,6 +53,9 @@
       <index name="AD_ORGWAREHOUSE_ORG_IDX" unique="false">
         <index-column name="AD_ORG_ID"/>
       </index>
+      <index name="AD_ORGWAREHOUSE_WH_IDX" unique="false">
+        <index-column name="M_WAREHOUSE_ID"/>
+      </index>
       <unique name="AD_ORG_WAREHOUSE_WAREHOUSE_UN">
         <unique-column name="AD_ORG_ID"/>
         <unique-column name="M_WAREHOUSE_ID"/>
--- a/src-db/database/model/tables/M_RESERVATION.xml	Fri Aug 01 11:48:12 2014 +0530
+++ b/src-db/database/model/tables/M_RESERVATION.xml	Mon Aug 04 08:40:38 2014 +0200
@@ -123,6 +123,9 @@
       <foreign-key foreignTable="M_WAREHOUSE" name="M_RESERVATION_WAREHOUSE">
         <reference local="M_WAREHOUSE_ID" foreign="M_WAREHOUSE_ID"/>
       </foreign-key>
+      <index name="M_RESERVATION_ORDERLINE_IDX" unique="false">
+        <index-column name="C_ORDERLINE_ID"/>
+      </index>
       <index name="M_RESERVATION_PRODUCT_IDX" unique="false">
         <index-column name="M_PRODUCT_ID"/>
       </index>
--- a/src-db/database/model/tables/M_STOCK_PROPOSED.xml	Fri Aug 01 11:48:12 2014 +0530
+++ b/src-db/database/model/tables/M_STOCK_PROPOSED.xml	Mon Aug 04 08:40:38 2014 +0200
@@ -63,7 +63,7 @@
       <foreign-key foreignTable="AD_ORG" name="AD_ORG_MSTOCKPROPOSED">
         <reference local="AD_ORG_ID" foreign="AD_ORG_ID"/>
       </foreign-key>
-      <foreign-key foreignTable="AD_PINSTANCE" name="AD_PINSTANCE_MSTOCKPROPOSED">
+      <foreign-key foreignTable="AD_PINSTANCE" name="AD_PINSTANCE_MSTOCKPROPOSED" onDelete="cascade">
         <reference local="AD_PINSTANCE_ID" foreign="AD_PINSTANCE_ID"/>
       </foreign-key>
       <foreign-key foreignTable="M_STORAGE_DETAIL" name="M_STORAGEDET_MSTOCKPROPOSED">