diff --git a/base/src/org/compiere/model/MAttributeSetInstance.java b/base/src/org/compiere/model/MAttributeSetInstance.java index e5b42d567d..58a4740dbe 100644 --- a/base/src/org/compiere/model/MAttributeSetInstance.java +++ b/base/src/org/compiere/model/MAttributeSetInstance.java @@ -346,5 +346,34 @@ public class MAttributeSetInstance extends X_M_AttributeSetInstance return m_mas.isExcludeSerNo (AD_Column_ID, isSOTrx); return false; } // isExcludeSerNo - + + @Override + protected boolean afterSave(boolean newRecord, boolean success) + { + if (super.afterSave(newRecord, success)) + { + if (newRecord && success) + { + //use id as description when description is empty + String desc = this.getDescription(); + if (desc == null || desc.trim().length() == 0) + { + this.set_ValueNoCheck("Description", Integer.toString(getM_AttributeSetInstance_ID())); + String sql = "UPDATE M_AttributeSetInstance SET Description = ? WHERE M_AttributeSetInstance_ID = ?"; + int no = DB.executeUpdate(sql, + new Object[]{Integer.toString(getM_AttributeSetInstance_ID()), getM_AttributeSetInstance_ID()}, + false, get_TrxName()); + if (no <= 0) + { + log.log(Level.SEVERE, "Failed to update description."); + return false; + } + } + } + return true; + } + + return false; + } + } // MAttributeSetInstance