154155156157158159160161162163164
OrderElement newElement = parent.toLeaf(); if (!order.isCodeAutogenerated()) { newElement.setCode(UUID.randomUUID().toString()); } parent.getParent().replace(parent, newElement); parent.detachFromParent(); } orderModel.save(); }