IDEMPIERE-1405 Locator Dialog allows to create locators without any check (#651)

IDEMPIERE-4442 Change Locator Dialog ListBox to Tabledirect (autocomplete)
* Fix an issue not setting the new locator created when returning
This commit is contained in:
Carlos Ruiz 2021-04-19 14:45:21 +02:00 committed by GitHub
parent c803886d25
commit 9d059b13fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 13 deletions

View File

@ -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 ctx Context
* @param M_Warehouse_ID warehouse * @param M_Warehouse_ID warehouse
* @param Value value * @param Value value
* @param X x * @param X x
* @param Y y * @param Y y
* @param Z z * @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, public static MLocator get (Properties ctx, int M_Warehouse_ID, String Value,
String X, String Y, String Z, int M_LocatorType_ID) 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) if (retValue == null)
{ {
MWarehouse wh = MWarehouse.get (ctx, M_Warehouse_ID); if (MRole.getDefault().isTableAccess(MLocator.Table_ID, false)) {
retValue = new MLocator (wh, Value); MWarehouse wh = MWarehouse.get (ctx, M_Warehouse_ID);
retValue.setXYZ(X, Y, Z); retValue = new MLocator (wh, Value);
retValue.setM_LocatorType_ID(M_LocatorType_ID); retValue.setXYZ(X, Y, Z);
retValue.saveEx(); retValue.setM_LocatorType_ID(M_LocatorType_ID);
retValue.saveEx();
}
} }
return retValue; return retValue;
} // get } // get

View File

@ -401,6 +401,9 @@ public class WLocatorDialog extends Window implements EventListener<Event>
chkCreateNew.setChecked(false); chkCreateNew.setChecked(false);
chkCreateNew.addEventListener(Events.ON_CHECK, this); chkCreateNew.addEventListener(Events.ON_CHECK, this);
if (! MRole.getDefault().isTableAccess(MLocator.Table_ID, false)) {
chkCreateNew.setVisible(false);
}
enableNew(); enableNew();
@ -626,13 +629,14 @@ public class WLocatorDialog extends Window implements EventListener<Event>
MLocator loc = MLocator.get(Env.getCtx(), m_M_Warehouse_ID, txtKey.getText(), MLocator loc = MLocator.get(Env.getCtx(), m_M_Warehouse_ID, txtKey.getText(),
txtAisleX.getText(), txtBinY.getText(), txtLevelZ.getText(), lt); 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(); m_M_Locator_ID = loc.getM_Locator_ID();
listitem = new ListItem();
listitem.setValue(loc);
locatorField.actionRefresh(); locatorField.actionRefresh();
locatorField.getComponent().appendItem(loc.getValue(), m_M_Locator_ID);
locatorField.setValue(m_M_Locator_ID); locatorField.setValue(m_M_Locator_ID);
} // createNew } // createNew