[Warehouse]Implement on hand warehouse on get_stock.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Thu, 04 Oct 2012 09:58:49 +0200
changeset 18635 ecaa80a3fae4
parent 18634 152773f32337
child 18636 a2190673380b
[Warehouse]Implement on hand warehouse on get_stock.
src-db/database/model/functions/M_GET_STOCK.xml
--- a/src-db/database/model/functions/M_GET_STOCK.xml	Thu Oct 04 09:58:29 2012 +0200
+++ b/src-db/database/model/functions/M_GET_STOCK.xml	Thu Oct 04 09:58:49 2012 +0200
@@ -137,6 +137,7 @@
        JOIN M_STOCK_AUX MS ON T.M_STORAGE_DETAIL_ID = MS.M_STORAGE_DETAIL_ID
        JOIN M_LOCATOR L ON T.M_LOCATOR_ID=L.M_LOCATOR_ID
        JOIN M_WAREHOUSE W ON L.M_WAREHOUSE_ID = W.M_WAREHOUSE_ID
+       JOIN AD_ORG_WAREHOUSE ow ON W.M_WAREHOUSE_ID = ow.M_WAREHOUSE_ID
                 LEFT JOIN M_PRODUCT_UOM PU ON T.M_PRODUCT_UOM_ID = PU.M_PRODUCT_UOM_ID
                 LEFT JOIN C_UOM U ON PU.C_UOM_ID = U.C_UOM_ID
         WHERE T.M_PRODUCT_ID=v_ProductID
@@ -148,9 +149,9 @@
         AND COALESCE(T.M_ATTRIBUTESETINSTANCE_ID, '-1') = COALESCE(v_AttributesetinstanceID, T.M_ATTRIBUTESETINSTANCE_ID, '-1')
         AND COALESCE(L.M_LOCATOR_ID, '-1') = COALESCE(v_LocatorID, L.M_LOCATOR_ID, '-1')
         AND COALESCE(W.M_WAREHOUSE_ID, '-1') = COALESCE(v_WarehouseID, W.M_WAREHOUSE_ID, '-1')
-        AND ((AD_ISORGINCLUDED(W.AD_ORG_ID,v_OrgID,W.AD_CLIENT_ID)<>-1) OR (AD_ISORGINCLUDED(v_OrgID,W.AD_ORG_ID,W.AD_CLIENT_ID)<>-1))
+        AND ow.AD_ORG_ID = v_orgid
         AND COALESCE(MS.Quantity, 0)>0
-        ORDER BY PRIORITYNO, LASTUPDATED
+        ORDER BY OW.PRIORITY, L.PRIORITYNO, LASTUPDATED
       )
       LOOP
         INSERT 
@@ -176,17 +177,18 @@
       FROM M_STORAGE_DETAIL T 
        JOIN M_LOCATOR L ON T.M_LOCATOR_ID=L.M_LOCATOR_ID
        JOIN M_WAREHOUSE W ON L.M_WAREHOUSE_ID = W.M_WAREHOUSE_ID
-       LEFT JOIN M_PRODUCT_UOM PU ON T.M_PRODUCT_UOM_ID = PU.M_PRODUCT_UOM_ID
-       LEFT JOIN C_UOM U ON PU.C_UOM_ID = U.C_UOM_ID
+       JOIN AD_ORG_WAREHOUSE ow ON W.M_WAREHOUSE_ID = ow.M_WAREHOUSE_ID
+           LEFT JOIN M_PRODUCT_UOM PU ON T.M_PRODUCT_UOM_ID = PU.M_PRODUCT_UOM_ID
+           LEFT JOIN C_UOM U ON PU.C_UOM_ID = U.C_UOM_ID
       WHERE T.M_PRODUCT_ID=v_ProductID
         AND COALESCE(T.C_UOM_ID, '-1') = COALESCE(v_UomID, T.C_UOM_ID, '-1')
         AND COALESCE(T.M_Product_UOM_id, '-1') = COALESCE(v_ProductUomID, T.M_Product_UOM_id, '-1')
         AND COALESCE(T.M_ATTRIBUTESETINSTANCE_ID, '-1') = COALESCE(v_AttributesetinstanceID, T.M_ATTRIBUTESETINSTANCE_ID, '-1')
         AND COALESCE(L.M_LOCATOR_ID, '-1') = COALESCE(v_LocatorID, L.M_LOCATOR_ID, '-1')
         AND COALESCE(W.M_WAREHOUSE_ID, '-1') = COALESCE(v_WarehouseID, W.M_WAREHOUSE_ID, '-1')
-        AND ((AD_ISORGINCLUDED(W.AD_ORG_ID,v_OrgID,W.AD_CLIENT_ID)<>-1) OR (AD_ISORGINCLUDED(v_OrgID,W.AD_ORG_ID,W.AD_CLIENT_ID)<>-1))
+        AND ow.AD_ORG_ID = v_orgid
         AND COALESCE(T.QtyOnHand, 0)>0
-        ORDER BY PRIORITYNO, LASTUPDATED
+        ORDER BY OW.PRIORITY, L.PRIORITYNO, LASTUPDATED
       )
       LOOP
         INSERT