diff --git a/src/oscar_accounts/abstract_models.py b/src/oscar_accounts/abstract_models.py index 35c9535..ed4373a 100644 --- a/src/oscar_accounts/abstract_models.py +++ b/src/oscar_accounts/abstract_models.py @@ -146,8 +146,10 @@ def save(self, *args, **kwargs): if self.code: self.code = self.code.upper() # Ensure the balance is always correct when saving - self.balance = self._balance() - return super().save(*args, **kwargs) + # Django 4.2 requires a pk to use manager methods as in self._balance() + if self.pk is not None: + self.balance = self._balance() + super().save(*args, **kwargs) def _balance(self): aggregates = self.transactions.aggregate(sum=Sum('amount'))