From 79b5854a22a245368b93bc0248163c1fc5342ef6 Mon Sep 17 00:00:00 2001 From: tsvikruha Date: Wed, 25 Feb 2015 15:59:17 -0500 Subject: [PATCH] IDEMPIERE-2453 Deleting nodes from tree has strange behviour --- org.adempiere.base/src/org/compiere/model/PO.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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)