diff --git a/org.adempiere.base/src/org/adempiere/util/ModelClassGenerator.java b/org.adempiere.base/src/org/adempiere/util/ModelClassGenerator.java index 5b6acf501b..0da54de921 100644 --- a/org.adempiere.base/src/org/adempiere/util/ModelClassGenerator.java +++ b/org.adempiere.base/src/org/adempiere/util/ModelClassGenerator.java @@ -238,15 +238,21 @@ public class ModelClassGenerator .append(" {").append(NL) .append(" POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());").append(NL) .append(" return poi;").append(NL) - .append(" }").append(NL) + .append(" }").append(NL); // initPO + final String sqlCol = "SELECT COUNT(*) FROM AD_Column WHERE AD_Table_ID=? AND ColumnName=? AND IsActive='Y'"; + boolean hasName = (DB.getSQLValue(null, sqlCol, AD_Table_ID, "Name") == 1); // toString() - .append(NL) + start.append(NL) .append(" public String toString()").append(NL) .append(" {").append(NL) - .append(" StringBuffer sb = new StringBuffer (\"").append(className).append("[\")").append(NL) - .append(" .append(get_ID()).append(\"]\");").append(NL) + .append(" StringBuilder sb = new StringBuilder (\"").append(className).append("[\")").append(NL) + // TODO: generate getName if there is a Name column -- .append(",Name=").append(getName()) + .append(" .append(get_ID())"); + if (hasName) + start.append(".append(\",Name=\").append(getName())"); + start.append(".append(\"]\");").append(NL) .append(" return sb.toString();").append(NL) .append(" }").append(NL) ;