details: https://code.openbravo.com/erp/devel/pi/rev/4beee9b03fe7 changeset: 27318:4beee9b03fe7 user: Atul Gaware <atul.gaware <at> openbravo.com> date: Fri Aug 07 15:54:54 2015 +0530 summary: Fixes Issue 30463: Move a Storage Bin process of Goods Movement window allows to choose any locator without taking into account the organization
In case of Good Movements window with id 170, org id set in transaction is sent as a filter for locator selector. While applying default filters to Locator selector in Alias and Warehouse a check is provided to check whether login profile warehouse's organization is included under the organization selected in the transaction. details: https://code.openbravo.com/erp/devel/pi/rev/9bb014254be7 changeset: 27319:9bb014254be7 user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Thu Aug 13 12:41:06 2015 +0200 summary: Related to issue 30463: code review improvements Usage of constant for the Goods Movement window id Utility.getContext(this, vars, M_Warehouse_ID, windowId) called one time Avoid possible NPE when windowId is null diffstat: src/org/openbravo/erpCommon/info/Locator.java | 27 +++++++++++++++++---- src/org/openbravo/erpCommon/info/Locator_data.xsql | 14 ++++++++++- 2 files changed, 34 insertions(+), 7 deletions(-) diffs (82 lines): diff -r 092bf17c3613 -r 9bb014254be7 src/org/openbravo/erpCommon/info/Locator.java --- a/src/org/openbravo/erpCommon/info/Locator.java Thu Aug 13 12:03:24 2015 +0200 +++ b/src/org/openbravo/erpCommon/info/Locator.java Thu Aug 13 12:41:06 2015 +0200 @@ -46,6 +46,7 @@ "priorityno", "isdefault", "rowkey" }; private static final RequestFilter columnFilter = new ValueListFilter(colNames); private static final RequestFilter directionFilter = new ValueListFilter("asc", "desc"); + private static final String WINDOWID_GOODSMOVEMENT = "170"; public void init(ServletConfig config) { super.init(config); @@ -60,21 +61,35 @@ removePageSessionVariables(vars); String strName = vars.getRequestGlobalVariable("inpNameValue", "Locator.warehousename"); String strWarehouse = ""; + String strWarehouseId = ""; String windowId = vars.getRequestGlobalVariable("WindowID", "Locator.windowId"); + String strOrg = vars.getGlobalVariable("inpadOrgId", "Locator.adorgid", ""); - if (!windowId.equals("") && windowId != null) { - strWarehouse = LocatorData.selectname(this, - Utility.getContext(this, vars, "M_Warehouse_ID", windowId)); + if (windowId != null && !windowId.equals("")) { + strWarehouseId = Utility.getContext(this, vars, "M_Warehouse_ID", windowId); + strWarehouse = LocatorData.selectname(this, strWarehouseId); } if ("168".equals(windowId)) { strWarehouse = LocatorData.selectname(this, vars.getGlobalVariable("inpmWarehouseId", "168|m_warehouse_id", "")); + } else if (WINDOWID_GOODSMOVEMENT.equals(windowId)) { + // Fetch transaction Organization if window is Goods Movements + strOrg = vars.getGlobalVariable("inpadOrgId", WINDOWID_GOODSMOVEMENT + "|ad_org_id", ""); } - strName = strName + "%"; - strWarehouse = strWarehouse + "%"; + /** + * Check whether the login profile warehouse belongs to transaction organization selected + */ + String warehouseBelongsToOrg = LocatorData + .warehouseBelongsToOrg(this, strOrg, strWarehouseId); + if (!"-1".equals(warehouseBelongsToOrg)) { + strName = strName + "%"; + strWarehouse = strWarehouse + "%"; + } else { + strName = "%"; + strWarehouse = "%"; + } vars.setSessionValue("Locator.name", strName); vars.setSessionValue("Locator.warehousename", strWarehouse); - String strOrg = vars.getGlobalVariable("inpadOrgId", "Locator.adorgid", ""); vars.setSessionValue("Locator.adorgid", strOrg); if ("".equals(strOrg) || strOrg == null) { if ("184".equals(windowId) || "169".equals(windowId) || "800013".equals(windowId) diff -r 092bf17c3613 -r 9bb014254be7 src/org/openbravo/erpCommon/info/Locator_data.xsql --- a/src/org/openbravo/erpCommon/info/Locator_data.xsql Thu Aug 13 12:03:24 2015 +0200 +++ b/src/org/openbravo/erpCommon/info/Locator_data.xsql Thu Aug 13 12:41:06 2015 +0200 @@ -12,7 +12,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) 2001-2011 Openbravo SLU + * All portions are Copyright (C) 2001-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -117,4 +117,16 @@ </Sql> <Parameter name="mWarehouseId"/> </SqlMethod> + <SqlMethod name="warehouseBelongsToOrg" type="preparedStatement" return="string" default=""> + <SqlMethodComment></SqlMethodComment> + <Sql> + <![CDATA[ + SELECT ad_isorgincluded(mw.ad_org_id, ? ,mw.ad_client_id) + FROM M_Warehouse mw + WHERE mw.m_warehouse_id = ? + ]]> + </Sql> + <Parameter name="adOrgId"/> + <Parameter name="mWarehouseId"/> + </SqlMethod> </SqlClass> ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits