IDEMPIERE-2453 Deleting nodes from tree has strange behviour

This commit is contained in:
tsvikruha 2015-02-25 15:59:17 -05:00
parent 2e8a31d4d8
commit 79b5854a22
1 changed files with 8 additions and 0 deletions

View File

@ -3938,6 +3938,14 @@ public abstract class PO
int id = get_ID(); int id = get_ID();
if (id == 0) if (id == 0)
id = get_IDOld(); 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 ") StringBuilder sb = new StringBuilder ("DELETE FROM ")
.append(MTree_Base.getNodeTableName(treeType)) .append(MTree_Base.getNodeTableName(treeType))
.append(" n WHERE Node_ID=").append(id) .append(" n WHERE Node_ID=").append(id)