From 2286fb8f67f78c60ba61926a481aedbad4f4fbce Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 14 Nov 2019 20:38:16 +0100 Subject: [PATCH] IDEMPIERE-4106 Dependent fields not cleared when changing a parent field / IDEMPIERE-3961 --- .../src/org/compiere/model/GridTab.java | 8 +++++--- .../adempiere/webui/adwindow/ADTabpanel.java | 18 +----------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index ca57300f76..af8fe9ef3b 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -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); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java index 07bd5f0ca4..281f58f885 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java @@ -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)