diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderElement.java b/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderElement.java index fea3430a3..cb0a17c0d 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderElement.java +++ b/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderElement.java @@ -316,7 +316,7 @@ public abstract class OrderElement extends IntegrationEntity implements } else if (isSuperElementPartialOrCompletelyScheduled()) { removeUnscheduled(result); if (wasASchedulingPoint()) { - result.add(taskSourceRemoval()); + removeTaskSource(result); } else { if (hadATaskSource() && currentTaskSourceIsNotTheSame()) { //all the children of this element were unscheduled and then scheduled again, @@ -350,6 +350,14 @@ public abstract class OrderElement extends IntegrationEntity implements } private boolean wasASchedulingPoint() { + TaskSource currentTaskSource = getTaskSource(); + // check if the existing TaskSource is inconsistent with the current + // scheduling state + if (currentTaskSource != null && currentTaskSource.getTask().isLeaf() + && getSchedulingStateType() != Type.SCHEDULING_POINT) { + return true; + } + // check if the scheduling state has changed WRT the DB SchedulingDataForVersion currentVersionOnDB = getCurrentVersionOnDB(); return SchedulingState.Type.SCHEDULING_POINT == currentVersionOnDB .getSchedulingStateType();