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 30ce97fe4..0d4c6dee5 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 @@ -299,15 +299,16 @@ public abstract class OrderElement extends IntegrationEntity implements //this element was a container but now it's a scheduling point //we have to remove the TaskSource which contains a TaskGroup instead of TaskElement removeTaskSource(result); - } - if (hadATaskSource() && currentTaskSourceIsNotTheSame()) { - //this element was unscheduled and then scheduled again. Its TaskSource has - //been recreated but we have to remove the old one. - if(!getParent().currentTaskSourceIsNotTheSame()) { - //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); + } else { + if (hadATaskSource() && currentTaskSourceIsNotTheSame()) { + //this element was unscheduled and then scheduled again. Its TaskSource has + //been recreated but we have to remove the old one. + if(!getParent().currentTaskSourceIsNotTheSame()) { + //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 @@ -316,14 +317,15 @@ public abstract class OrderElement extends IntegrationEntity implements removeUnscheduled(result); if (wasASchedulingPoint()) { result.add(taskSourceRemoval()); - } - if (hadATaskSource() && currentTaskSourceIsNotTheSame()) { - //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. - if(getParent() == null || !getParent().currentTaskSourceIsNotTheSame()) { - //if it's a container node inside another container we could have the - //same problem than in the case of leaf tasks. - result.add(taskSourceRemoval()); + } else { + if (hadATaskSource() && currentTaskSourceIsNotTheSame()) { + //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. + if(getParent() == null || !getParent().currentTaskSourceIsNotTheSame()) { + //if it's a container node inside another container we could have the + //same problem than in the case of leaf tasks. + result.add(taskSourceRemoval()); + } } } result