From 4de3321f323e1a91cc0a7b1b5afa011265aa774a Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 6 Feb 2009 09:13:50 +0000 Subject: [PATCH] Merge 8325, hengsin, 04 February 2009 [ 2566493 ] Material receipt create instance with empty description - Use M_AttributeSetInstance_ID as description when description is null or empty. --- .../compiere/model/MAttributeSetInstance.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) 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