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 3d3683a35..297f8a4de 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 @@ -300,7 +300,12 @@ public abstract class OrderElement extends IntegrationEntity implements if(getOnDBTaskSource() != getTaskSource()) { //this element was unscheduled and then scheduled again. Its TaskSource has //been recreated but we have to remove the old one. - removeTaskSource(result); + if(getParent().getTaskSource() == getParent().getOnDBTaskSource()) { + //we only remove the TaskSource if the parent is not in the same situation. + //In case the parent is in the same situation, it will remove the related + //TaskSources in children tasks. + removeTaskSource(result); + } } result .addAll(synchronizationForSchedulingPoint(schedulingDataForVersion)); @@ -309,6 +314,11 @@ public abstract class OrderElement extends IntegrationEntity implements if (wasASchedulingPoint()) { result.add(taskSourceRemoval()); } + if(getOnDBTaskSource() != getTaskSource()) { + //all the children of this element were unscheduled and then scheduled again, + //its TaskSource has been recreated but we have to remove the old one. + result.add(taskSourceRemoval()); + } result .add(synchronizationForSuperelement(schedulingDataForVersion)); } else if (schedulingState.isNoScheduled()) { @@ -417,7 +427,7 @@ public abstract class OrderElement extends IntegrationEntity implements } } - private TaskSource getOnDBTaskSource() { + protected TaskSource getOnDBTaskSource() { SchedulingDataForVersion schedulingDataForVersion = getCurrentVersionOnDB(); return schedulingDataForVersion.getTaskSource(); }