From ea5371040e766a3995beebe13766f8030004cf4a Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 30 Dec 2025 11:05:08 -0500 Subject: [PATCH] Fixes #20817: Re-enable sync button when disabling scheduled syncing for a data source (#21055) --- netbox/core/models/data.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/netbox/core/models/data.py b/netbox/core/models/data.py index 52a11c58e..78adb14f5 100644 --- a/netbox/core/models/data.py +++ b/netbox/core/models/data.py @@ -131,6 +131,19 @@ class DataSource(JobsMixin, PrimaryModel): 'source_url': "URLs for local sources must start with file:// (or specify no scheme)" }) + def save(self, *args, **kwargs): + + # If recurring sync is disabled for an existing DataSource, clear any pending sync jobs for it and reset its + # "queued" status + if not self._state.adding and not self.sync_interval: + self.jobs.filter(status=JobStatusChoices.STATUS_PENDING).delete() + if self.status == DataSourceStatusChoices.QUEUED and self.last_synced: + self.status = DataSourceStatusChoices.COMPLETED + elif self.status == DataSourceStatusChoices.QUEUED: + self.status = DataSourceStatusChoices.NEW + + super().save(*args, **kwargs) + def to_objectchange(self, action): objectchange = super().to_objectchange(action)