IDEMPIERE-4106 Dependent fields not cleared when changing a parent field / IDEMPIERE-3961

This commit is contained in:
Carlos Ruiz 2019-11-14 20:38:16 +01:00
parent 9496b01a2b
commit 2286fb8f67
2 changed files with 6 additions and 20 deletions

View File

@ -2771,8 +2771,9 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
// Get dependent MFields (may be because of display or dynamic lookup)
for (GridField dependentField : getDependantFields(columnName))
{
if (dependentField == null || dependentField.isLookupEditorSettingValue()) continue;
if (dependentField == null || dependentField.isLookupEditorSettingValue())
continue;
// if the field has a lookup
if (dependentField.getLookup() instanceof MLookup)
{
@ -2783,12 +2784,13 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
if (log.isLoggable(Level.FINE)) log.fine(columnName + " changed - "
+ dependentField.getColumnName() + " set to null");
mLookup.refresh();
Object currentValue = dependentField.getValue();
// invalidate current selection
setValue(dependentField, null);
if (currentValue != null && mLookup.containsKey(currentValue))
if (currentValue != null && mLookup.containsKeyNoDirect(currentValue))
setValue(dependentField, currentValue);
}
}

View File

@ -68,7 +68,6 @@ import org.compiere.model.GridTable;
import org.compiere.model.GridWindow;
import org.compiere.model.I_AD_Preference;
import org.compiere.model.MColumn;
import org.compiere.model.MLookup;
import org.compiere.model.MPreference;
import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
@ -1369,27 +1368,12 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|| (Core.findCallout(gridTab.getTableName(), mField.getColumnName())).size()>0
|| gridTab.hasDependants(mField.getColumnName())))
{
// IDEMPIERE-4106 Refresh the list (lookup) on dependant fields was moved inside processFieldChange->processDependencies
String msg = gridTab.processFieldChange(mField); // Dependencies & Callout
if (msg.length() > 0)
{
FDialog.error(windowNo, this, msg);
}
// Refresh the list on dependant fields
for (GridField dependentField : gridTab.getDependantFields(mField.getColumnName()))
{
// if the field has a lookup
if (dependentField != null && dependentField.getLookup() instanceof MLookup)
{
MLookup mLookup = (MLookup)dependentField.getLookup();
// if the lookup is dynamic (i.e. contains this columnName as variable)
if (mLookup.getValidation().indexOf("@"+mField.getColumnName()+"@") != -1)
{
mLookup.refresh();
}
}
} // for all dependent fields
}
//if (col >= 0)
if (!uiCreated)