diff --git a/org.adempiere.base/src/org/compiere/model/MLocator.java b/org.adempiere.base/src/org/compiere/model/MLocator.java index dc8aa78776..c8c26b04d5 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocator.java +++ b/org.adempiere.base/src/org/compiere/model/MLocator.java @@ -125,14 +125,14 @@ public class MLocator extends X_M_Locator implements ImmutablePOSupport } /** - * Get the Locator with the combination or create new one + * Get the Locator with the combination or create new one (when user has permission) * @param ctx Context * @param M_Warehouse_ID warehouse * @param Value value * @param X x * @param Y y * @param Z z - * @return locator + * @return locator (or null when no insert permission on MLocator) */ public static MLocator get (Properties ctx, int M_Warehouse_ID, String Value, String X, String Y, String Z, int M_LocatorType_ID) @@ -163,11 +163,13 @@ public class MLocator extends X_M_Locator implements ImmutablePOSupport // if (retValue == null) { - MWarehouse wh = MWarehouse.get (ctx, M_Warehouse_ID); - retValue = new MLocator (wh, Value); - retValue.setXYZ(X, Y, Z); - retValue.setM_LocatorType_ID(M_LocatorType_ID); - retValue.saveEx(); + if (MRole.getDefault().isTableAccess(MLocator.Table_ID, false)) { + MWarehouse wh = MWarehouse.get (ctx, M_Warehouse_ID); + retValue = new MLocator (wh, Value); + retValue.setXYZ(X, Y, Z); + retValue.setM_LocatorType_ID(M_LocatorType_ID); + retValue.saveEx(); + } } return retValue; } // get diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java index 5b0f48ac12..918f17580f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java @@ -401,7 +401,10 @@ public class WLocatorDialog extends Window implements EventListener chkCreateNew.setChecked(false); chkCreateNew.addEventListener(Events.ON_CHECK, this); - + if (! MRole.getDefault().isTableAccess(MLocator.Table_ID, false)) { + chkCreateNew.setVisible(false); + } + enableNew(); lstWarehouse.addEventListener(Events.ON_SELECT, this); @@ -626,13 +629,14 @@ public class WLocatorDialog extends Window implements EventListener MLocator loc = MLocator.get(Env.getCtx(), m_M_Warehouse_ID, txtKey.getText(), txtAisleX.getText(), txtBinY.getText(), txtLevelZ.getText(), lt); - + if (loc == null) { + FDialog.error(m_WindowNo, this, "AccessCannotInsert", Msg.getElement(Env.getCtx(), "M_Locator_ID")); + return; + } m_M_Locator_ID = loc.getM_Locator_ID(); - - listitem = new ListItem(); - listitem.setValue(loc); - + locatorField.actionRefresh(); + locatorField.getComponent().appendItem(loc.getValue(), m_M_Locator_ID); locatorField.setValue(m_M_Locator_ID); } // createNew