mirror of
https://github.com/pretix/pretix.git
synced 2026-05-10 16:04:02 +00:00
Fixed transaction handling problem if a race condition occurs during invoice creation
This commit is contained in:
@@ -2,7 +2,7 @@ import string
|
|||||||
from datetime import date
|
from datetime import date
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from django.db import DatabaseError, models
|
from django.db import DatabaseError, models, transaction
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
from django.utils.crypto import get_random_string
|
from django.utils.crypto import get_random_string
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
@@ -88,7 +88,8 @@ class Invoice(models.Model):
|
|||||||
else:
|
else:
|
||||||
self.invoice_no = self._get_invoice_number_from_order()
|
self.invoice_no = self._get_invoice_number_from_order()
|
||||||
try:
|
try:
|
||||||
return super().save(*args, **kwargs)
|
with transaction.atomic():
|
||||||
|
return super().save(*args, **kwargs)
|
||||||
except DatabaseError:
|
except DatabaseError:
|
||||||
# Suppress duplicate key errors and try again
|
# Suppress duplicate key errors and try again
|
||||||
if i == 9:
|
if i == 9:
|
||||||
|
|||||||
Reference in New Issue
Block a user