IDEMPIERE-2781 Client Field empty when adding a record on System / IDEMPIERE-2672
This commit is contained in:
parent
cc18b9f146
commit
2f0204288c
|
@ -278,8 +278,11 @@ public class GridField
|
||||||
*/
|
*/
|
||||||
public boolean refreshLookup()
|
public boolean refreshLookup()
|
||||||
{
|
{
|
||||||
// if there is a validation string, the lookup is unstable
|
if (m_lookup == null)
|
||||||
if (m_lookup == null || m_lookup.getValidation().length() == 0)
|
return true;
|
||||||
|
|
||||||
|
// if there is a validation string, the lookup is unstable - read-only fields are not loaded initially
|
||||||
|
if (m_lookup.getValidation().length() == 0 && m_lookup.isLoaded())
|
||||||
return true;
|
return true;
|
||||||
//
|
//
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("(" + m_vo.ColumnName + ")");
|
if (log.isLoggable(Level.FINE)) log.fine("(" + m_vo.ColumnName + ")");
|
||||||
|
@ -836,7 +839,7 @@ public class GridField
|
||||||
// need to re-set invalid values - OK BPartner in PO Line - not OK SalesRep in Invoice
|
// need to re-set invalid values - OK BPartner in PO Line - not OK SalesRep in Invoice
|
||||||
if (m_lookup.getDirect(m_value, false, true) == null)
|
if (m_lookup.getDirect(m_value, false, true) == null)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " Serach not valid - set to null");
|
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " Search not valid - set to null");
|
||||||
setValue(null, m_inserting);
|
setValue(null, m_inserting);
|
||||||
m_error = true;
|
m_error = true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -845,14 +848,24 @@ public class GridField
|
||||||
}
|
}
|
||||||
|
|
||||||
// cannot be validated
|
// cannot be validated
|
||||||
if (!isLookup()
|
if (!isLookup() || m_lookup == null)
|
||||||
|| m_lookup == null
|
|
||||||
|| m_lookup.containsKeyNoDirect(m_value))
|
|
||||||
return true;
|
return true;
|
||||||
|
if (m_lookup.containsKeyNoDirect(m_value)) {
|
||||||
|
String name = m_lookup.get(m_value).getName();
|
||||||
|
if (! ( name.startsWith(MLookup.INACTIVE_S) && name.endsWith(MLookup.INACTIVE_E) ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
// it's not null, a lookup and does not have the key
|
// it's not null, a lookup and does not have the key
|
||||||
if (isKey() || isParentValue()) // parents/ket are not validated
|
if (isKey() || isParentValue()) // parents/ket are not validated
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// special case for IDEMPIERE-2781
|
||||||
|
if ( "AD_Client_ID".equals(m_vo.ColumnName)
|
||||||
|
&& "0".equals(m_value.toString())
|
||||||
|
&& Env.getAD_Client_ID(Env.getCtx()) == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " - set to null");
|
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " - set to null");
|
||||||
setValue(null, m_inserting);
|
setValue(null, m_inserting);
|
||||||
m_error = true;
|
m_error = true;
|
||||||
|
@ -884,7 +897,7 @@ public class GridField
|
||||||
// need to re-set invalid values - OK BPartner in PO Line - not OK SalesRep in Invoice
|
// need to re-set invalid values - OK BPartner in PO Line - not OK SalesRep in Invoice
|
||||||
if (m_lookup.getDirect(m_value, false, true) == null)
|
if (m_lookup.getDirect(m_value, false, true) == null)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " Serach not valid - set to null");
|
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " Search not valid - set to null");
|
||||||
setValue(null, m_inserting);
|
setValue(null, m_inserting);
|
||||||
m_error = true;
|
m_error = true;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1186,10 +1186,9 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
setCurrentRow(m_currentRow + 1, true);
|
setCurrentRow(m_currentRow + 1, true);
|
||||||
|
|
||||||
// check validity of defaults
|
// check validity of defaults
|
||||||
for (int i = 0; i < getFieldCount(); i++)
|
for (GridField field : getFields()) {
|
||||||
{
|
field.refreshLookup();
|
||||||
getField(i).refreshLookup();
|
field.validateValueNoDirect();
|
||||||
getField(i).validateValueNoDirect();
|
|
||||||
}
|
}
|
||||||
// process all Callouts (no dependency check - assumed that settings are valid)
|
// process all Callouts (no dependency check - assumed that settings are valid)
|
||||||
for (int i = 0; i < getFieldCount(); i++)
|
for (int i = 0; i < getFieldCount(); i++)
|
||||||
|
|
|
@ -528,11 +528,16 @@ public final class MLookup extends Lookup implements Serializable
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
String name = rs.getString(3);
|
StringBuilder name = new StringBuilder().append(rs.getString(3));
|
||||||
|
boolean isActive = rs.getString(4).equals("Y");
|
||||||
|
if (!isActive)
|
||||||
|
{
|
||||||
|
name.insert(0, INACTIVE_S).append(INACTIVE_E);
|
||||||
|
}
|
||||||
if (isNumber)
|
if (isNumber)
|
||||||
{
|
{
|
||||||
int keyValue = rs.getInt(1);
|
int keyValue = rs.getInt(1);
|
||||||
KeyNamePair p = new KeyNamePair(keyValue, name);
|
KeyNamePair p = new KeyNamePair(keyValue, name.toString());
|
||||||
if (saveInCache) // save if
|
if (saveInCache) // save if
|
||||||
m_lookup.put(new Integer(keyValue), p);
|
m_lookup.put(new Integer(keyValue), p);
|
||||||
directValue = p;
|
directValue = p;
|
||||||
|
@ -540,7 +545,7 @@ public final class MLookup extends Lookup implements Serializable
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String value = rs.getString(2);
|
String value = rs.getString(2);
|
||||||
ValueNamePair p = new ValueNamePair(value, name);
|
ValueNamePair p = new ValueNamePair(value, name.toString());
|
||||||
if (saveInCache) // save if
|
if (saveInCache) // save if
|
||||||
m_lookup.put(value, p);
|
m_lookup.put(value, p);
|
||||||
directValue = p;
|
directValue = p;
|
||||||
|
@ -855,7 +860,7 @@ public final class MLookup extends Lookup implements Serializable
|
||||||
boolean isActive = rs.getString(4).equals("Y");
|
boolean isActive = rs.getString(4).equals("Y");
|
||||||
if (!isActive)
|
if (!isActive)
|
||||||
{
|
{
|
||||||
name = new StringBuilder(INACTIVE_S).append(name).append(INACTIVE_E);
|
name.insert(0, INACTIVE_S).append(INACTIVE_E);
|
||||||
m_hasInactive = true;
|
m_hasInactive = true;
|
||||||
}
|
}
|
||||||
// IDEMPIERE 90
|
// IDEMPIERE 90
|
||||||
|
|
|
@ -15,6 +15,8 @@ package org.adempiere.webui.editor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import static org.compiere.model.SystemIDs.COLUMN_M_PRODUCT_M_ATTRIBUTESETINSTANCE_ID;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.webui.apps.AEnv;
|
import org.adempiere.webui.apps.AEnv;
|
||||||
|
@ -29,9 +31,6 @@ import org.adempiere.webui.window.WPAttributeDialog;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.Lookup;
|
import org.compiere.model.Lookup;
|
||||||
import org.compiere.model.MAttributeSet;
|
|
||||||
import org.compiere.model.MProduct;
|
|
||||||
import static org.compiere.model.SystemIDs.*;
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
|
Loading…
Reference in New Issue