diff --git a/apps/note/models/transactions.py b/apps/note/models/transactions.py index bfe39a42..e0aa30f4 100644 --- a/apps/note/models/transactions.py +++ b/apps/note/models/transactions.py @@ -3,6 +3,7 @@ from django.core.exceptions import ValidationError from django.db import models, transaction +from django.db.models import F from django.urls import reverse from django.utils import timezone from django.utils.translation import gettext_lazy as _ @@ -217,6 +218,9 @@ class Transaction(PolymorphicModel): # When source == destination, no money is transferred and no transaction is created return + self.source = Note.objects.select_for_update().get(pk=self.source_id) + self.destination = Note.objects.select_for_update().get(pk=self.destination_id) + # Check that the amounts stay between big integer bounds diff_source, diff_dest = self.validate()