Ver código fonte

Fixes #14952: Update existing AutoSyncRecord when changing the data file of an auto-synced object

Jeremy Stretch 2 anos atrás
pai
commit
de5c5aeb2a
1 arquivos alterados com 3 adições e 3 exclusões
  1. 3 3
      netbox/netbox/models/features.py

+ 3 - 3
netbox/netbox/models/features.py

@@ -489,10 +489,10 @@ class SyncedDataMixin(models.Model):
         # Create/delete AutoSyncRecord as needed
         # Create/delete AutoSyncRecord as needed
         content_type = ContentType.objects.get_for_model(self)
         content_type = ContentType.objects.get_for_model(self)
         if self.auto_sync_enabled:
         if self.auto_sync_enabled:
-            AutoSyncRecord.objects.get_or_create(
-                datafile=self.data_file,
+            AutoSyncRecord.objects.update_or_create(
                 object_type=content_type,
                 object_type=content_type,
-                object_id=self.pk
+                object_id=self.pk,
+                defaults={'datafile': self.data_file}
             )
             )
         else:
         else:
             AutoSyncRecord.objects.filter(
             AutoSyncRecord.objects.filter(