diff --git a/migration/i1.0c-release/oracle/201310231101_IDEMPIERE-1459.sql b/migration/i1.0c-release/oracle/201310231101_IDEMPIERE-1459.sql new file mode 100644 index 0000000000..5d74e84645 --- /dev/null +++ b/migration/i1.0c-release/oracle/201310231101_IDEMPIERE-1459.sql @@ -0,0 +1,77 @@ +--IDEMPIERE-1459 - Improving performance on InfoWindows +CREATE OR REPLACE VIEW M_PRODUCT_STOCK_V +AS +SELECT +ms.IsActive, ms.Created, ms.CreatedBy, ms.Updated, ms.UpdatedBy, +mp.VALUE, mp.help, (ms.qtyonhand - ms.qtyreserved) AS qtyavailable, ms.qtyonhand, +ms.qtyreserved, mp.description, mw.NAME AS warehouse, mw.m_warehouse_id, mw.ad_client_id, +mw.ad_org_id, mp.documentnote, mp.m_product_id +FROM M_STORAGE ms +JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id +JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id +JOIN M_WAREHOUSE mw ON ml.m_warehouse_id = mw.m_warehouse_id +ORDER BY mw.NAME; + +--IDEMPIERE-1459 - Improving performance on InfoWindows +CREATE OR REPLACE VIEW m_storage +AS + SELECT s.m_product_id, + s.m_locator_id, + s.ad_client_id, + s.ad_org_id, + s.isactive, + s.created, + s.createdby, + s.updated, + s.updatedby, + s.qtyonhand, + 0 AS qtyreserved, + 0 AS qtyordered, + s.datelastinventory, + s.m_attributesetinstance_id, + s.m_storageonhand_uu AS m_storage_uu + FROM m_storageonhand s + UNION ALL + SELECT sr.m_product_id, + w.m_reservelocator_id AS m_locator_id, + sr.ad_client_id, + sr.ad_org_id, + sr.isactive, + sr.created, + sr.createdby, + sr.updated, + sr.updatedby, + 0 AS qtyonhand, + sr.qty AS qtyreserved, + 0 AS qtyordered, + sr.datelastinventory, + sr.m_attributesetinstance_id, + sr.m_storagereservation_uu AS m_storage_uu + FROM m_storagereservation sr + JOIN m_warehouse w + ON sr.m_warehouse_id = w.m_warehouse_id + WHERE sr.issotrx = 'Y' + UNION ALL + SELECT so.m_product_id, + w.m_reservelocator_id AS m_locator_id, + so.ad_client_id, + so.ad_org_id, + so.isactive, + so.created, + so.createdby, + so.updated, + so.updatedby, + 0 AS qtyonhand, + 0 AS qtyreserved, + so.qty AS qtyordered, + so.datelastinventory, + so.m_attributesetinstance_id, + so.m_storagereservation_uu AS m_storage_uu + FROM m_storagereservation so + JOIN m_warehouse w + ON so.m_warehouse_id = w.m_warehouse_id + WHERE so.issotrx = 'N' +; + +SELECT register_migration_script('201310231101_IDEMPIERE-1459.sql') FROM dual +; diff --git a/migration/i1.0c-release/postgresql/201310231101_IDEMPIERE-1459.sql b/migration/i1.0c-release/postgresql/201310231101_IDEMPIERE-1459.sql new file mode 100644 index 0000000000..f5b2602fde --- /dev/null +++ b/migration/i1.0c-release/postgresql/201310231101_IDEMPIERE-1459.sql @@ -0,0 +1,78 @@ +--IDEMPIERE-1459 - Improving performance on InfoWindows +CREATE OR REPLACE VIEW M_PRODUCT_STOCK_V +AS +SELECT +ms.IsActive, ms.Created, ms.CreatedBy, ms.Updated, ms.UpdatedBy, +mp.VALUE, mp.help, (ms.qtyonhand - ms.qtyreserved) AS qtyavailable, ms.qtyonhand, +ms.qtyreserved, mp.description, mw.NAME AS warehouse, mw.m_warehouse_id, mw.ad_client_id, +mw.ad_org_id, mp.documentnote, mp.m_product_id +FROM M_STORAGE ms +JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id +JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id +JOIN M_WAREHOUSE mw ON ml.m_warehouse_id = mw.m_warehouse_id +ORDER BY mw.NAME; + +--IDEMPIERE-1459 - Improving performance on InfoWindows +CREATE OR REPLACE VIEW m_storage +AS + SELECT s.m_product_id, + s.m_locator_id, + s.ad_client_id, + s.ad_org_id, + s.isactive, + s.created, + s.createdby, + s.updated, + s.updatedby, + s.qtyonhand, + 0 AS qtyreserved, + 0 AS qtyordered, + s.datelastinventory, + s.m_attributesetinstance_id, + s.m_storageonhand_uu AS m_storage_uu + FROM m_storageonhand s + UNION ALL + SELECT sr.m_product_id, + w.m_reservelocator_id AS m_locator_id, + sr.ad_client_id, + sr.ad_org_id, + sr.isactive, + sr.created, + sr.createdby, + sr.updated, + sr.updatedby, + 0 AS qtyonhand, + sr.qty AS qtyreserved, + 0 AS qtyordered, + sr.datelastinventory, + sr.m_attributesetinstance_id, + sr.m_storagereservation_uu AS m_storage_uu + FROM m_storagereservation sr + JOIN m_warehouse w + ON sr.m_warehouse_id = w.m_warehouse_id + WHERE sr.issotrx = 'Y' + UNION ALL + SELECT so.m_product_id, + w.m_reservelocator_id AS m_locator_id, + so.ad_client_id, + so.ad_org_id, + so.isactive, + so.created, + so.createdby, + so.updated, + so.updatedby, + 0 AS qtyonhand, + 0 AS qtyreserved, + so.qty AS qtyordered, + so.datelastinventory, + so.m_attributesetinstance_id, + so.m_storagereservation_uu AS m_storage_uu + FROM m_storagereservation so + JOIN m_warehouse w + ON so.m_warehouse_id = w.m_warehouse_id + WHERE so.issotrx = 'N' +; + + +SELECT register_migration_script('201310231101_IDEMPIERE-1459.sql') FROM dual +; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java index e050f87f09..403f4edf35 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java @@ -156,7 +156,7 @@ public class InfoProductWindow extends InfoWindow { /** From Clause */ String s_sqlFrom = " M_PRODUCT_STOCK_V "; /** Where Clause */ - String s_sqlWhere = "Value = ?"; + String s_sqlWhere = "M_Product_ID = ?"; warehouseTbl = ListboxFactory.newDataTable(); m_sqlWarehouse = warehouseTbl.prepareTable(s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V"); m_sqlWarehouse += " GROUP BY Warehouse"; @@ -331,7 +331,7 @@ public class InfoProductWindow extends InfoWindow { for(int i = 0; i < columnInfos.length; i++) { if (columnInfos[i].getGridField() != null && columnInfos[i].getGridField().getColumnName().equals("Value")) { - refresh(contentPanel.getValueAt(row,i), M_Warehouse_ID, M_PriceList_Version_ID); + refresh(M_Warehouse_ID, M_PriceList_Version_ID); contentBorderLayout.getSouth().setOpen(true); break; } @@ -530,9 +530,9 @@ public class InfoProductWindow extends InfoWindow { /** * Refresh Query */ - private void refresh(Object obj, int M_Warehouse_ID, int M_PriceList_Version_ID) + private void refresh(int M_Warehouse_ID, int M_PriceList_Version_ID) { - //int M_Product_ID = 0; + int m_M_Product_ID = getSelectedRowKey(); String sql = m_sqlWarehouse; if (log.isLoggable(Level.FINEST)) log.finest(sql); PreparedStatement pstmt = null; @@ -540,7 +540,7 @@ public class InfoProductWindow extends InfoWindow { try { pstmt = DB.prepareStatement(sql, null); - pstmt.setString(1, (String)obj); + pstmt.setInt(1, m_M_Product_ID); rs = pstmt.executeQuery(); warehouseTbl.loadTable(rs); } @@ -554,7 +554,6 @@ public class InfoProductWindow extends InfoWindow { rs = null; pstmt = null; } - int m_M_Product_ID = getSelectedRowKey(); sql = "SELECT DocumentNote FROM M_Product WHERE M_Product_ID=?"; fieldDescription.setText(DB.getSQLValueString(null, sql, m_M_Product_ID));