From 2acba874ecbdeb77bbe146aa5d618d9d464c49ec Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Tue, 29 Aug 2023 06:09:13 +0000
Subject: [PATCH] Only update specifications_doc in state
 defined/scheduling/scheduled, and feedback_doc in state-finishing

---
 SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py
index 4e443520d9b..e5fcd0b6072 100644
--- a/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py
+++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py
@@ -631,11 +631,12 @@ class Dataproduct(RefreshFromDbInvalidatesCachedPropertiesMixin, TemplateSchemaM
         self.validate_doc_using_template('specifications_doc', 'specifications_template')
 
     def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
-        if self.producer.subtask.state.value != SubtaskState.Choices.FINISHED.value:
+        if self.producer.subtask.state.value in (SubtaskState.Choices.DEFINED.value, SubtaskState.Choices.SCHEDULING.value, SubtaskState.Choices.SCHEDULED.value):
             self.annotate_doc_using_template('specifications_doc', 'specifications_template')
             self.add_defaults_to_doc_using_template('specifications_doc', 'specifications_template')
             self.validate_doc_using_template('specifications_doc', 'specifications_template')
 
+        if self.producer.subtask.state.value == SubtaskState.Choices.FINISHING.value:
             self.annotate_doc_using_template('feedback_doc', 'feedback_template')
             self.validate_doc_using_template('feedback_doc', 'feedback_template')
 
-- 
GitLab