diff --git a/apps/accounts/automations/change_secret/manager.py b/apps/accounts/automations/change_secret/manager.py index 0b56cc5c7..cb00b3a91 100644 --- a/apps/accounts/automations/change_secret/manager.py +++ b/apps/accounts/automations/change_secret/manager.py @@ -180,7 +180,7 @@ class ChangeSecretManager(AccountBasePlaybookManager): while retry_count < max_retries: try: recorder.save() - account.save(update_fields=['secret', 'version', 'date_updated']) + account.save(update_fields=['secret', 'date_updated']) break except Exception as e: retry_count += 1 diff --git a/apps/accounts/models/mixins/vault.py b/apps/accounts/models/mixins/vault.py index d61bc18bb..f3bbb4f88 100644 --- a/apps/accounts/models/mixins/vault.py +++ b/apps/accounts/models/mixins/vault.py @@ -80,6 +80,7 @@ class VaultModelMixin(models.Model): def mark_secret_save_to_vault(self): self._secret = self._secret_save_to_vault_mark + self.skip_history_when_saving = True self.save() @property diff --git a/apps/accounts/signal_handlers.py b/apps/accounts/signal_handlers.py index fefd50132..ec2e82b91 100644 --- a/apps/accounts/signal_handlers.py +++ b/apps/accounts/signal_handlers.py @@ -23,6 +23,9 @@ logger = get_logger(__name__) @receiver(pre_save, sender=Account) def on_account_pre_save(sender, instance, **kwargs): + if getattr(instance, 'skip_history_when_saving', False): + return + if instance.version == 0: instance.version = 1 else: