diff --git a/arches/app/models/models.py b/arches/app/models/models.py index 5c7a243ec0..22bd7c7932 100644 --- a/arches/app/models/models.py +++ b/arches/app/models/models.py @@ -915,18 +915,21 @@ def __init__(self, *args, **kwargs): def clean(self): if not self.alias: Graph.objects.get(pk=self.graph_id).create_node_alias(self) - if not self.grouping_node_id: - self.grouping_node_id = self.nodegroup_id + self.grouping_node_id = self.nodegroup_id + if self.pk == self.source_identifier_id: + self.source_identifier_id = None def save(self, **kwargs): - if not self.alias or not self.grouping_node_id: - self.clean() + if not self.alias: add_to_update_fields(kwargs, "alias") add_to_update_fields(kwargs, "hascustomalias") + if self.grouping_node_id != self.nodegroup_id: add_to_update_fields(kwargs, "grouping_node_id") if self.pk == self.source_identifier_id: - self.source_identifier_id = None add_to_update_fields(kwargs, "source_identifier_id") + + self.clean() + super(Node, self).save() class Meta: