diff --git a/apps/accounts/models/account.py b/apps/accounts/models/account.py index b611b29f1..e9ee2d1e1 100644 --- a/apps/accounts/models/account.py +++ b/apps/accounts/models/account.py @@ -23,6 +23,7 @@ class AccountHistoricalRecords(HistoricalRecords): super().__init__(*args, **kwargs) def post_save(self, instance, created, using=None, **kwargs): + self.updated_version = None if not self.included_fields: return super().post_save(instance, created, using=using, **kwargs) @@ -51,7 +52,10 @@ class AccountHistoricalRecords(HistoricalRecords): super().create_historical_record(instance, history_type, using=using) # Ignore deletion history_type: - if self.updated_version is not None and history_type != '-': - instance.save(update_fields=['version']) + type(instance)._base_manager.db_manager(using=using).filter( + pk=instance.pk + ).update(version=self.updated_version) + self.updated_version = None def create_history_model(self, model, inherited): if self.included_fields and not self.excluded_fields: