Skip to content

Commit e9ef87a

Browse files
fix Account.save()
1 parent bd2ec46 commit e9ef87a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/oscar_accounts/abstract_models.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ def save(self, *args, **kwargs):
146146
if self.code:
147147
self.code = self.code.upper()
148148
# Ensure the balance is always correct when saving
149-
self.balance = self._balance()
150-
return super().save(*args, **kwargs)
149+
# Django 4.2 requires a pk to use manager methods as in self._balance()
150+
if self.pk is not None:
151+
self.balance = self._balance()
152+
super().save()
151153

152154
def _balance(self):
153155
aggregates = self.transactions.aggregate(sum=Sum('amount'))

0 commit comments

Comments
 (0)