diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index 93e76913d2..7eb44df8b9 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -3938,6 +3938,14 @@ public abstract class PO int id = get_ID(); if (id == 0) id = get_IDOld(); + + // IDEMPIERE-2453 + StringBuilder countSql = new StringBuilder("SELECT COUNT(*) FROM ") + .append(MTree_Base.getNodeTableName(treeType)) + .append(" WHERE Parent_ID=?"); + if(DB.getSQLValue( get_TrxName(), countSql.toString(), id) > 0) + throw new AdempiereException("CannotDeleteParent"); + StringBuilder sb = new StringBuilder ("DELETE FROM ") .append(MTree_Base.getNodeTableName(treeType)) .append(" n WHERE Node_ID=").append(id)