Move bulk_create logic during bulk voucher creation

This commit is contained in:
Raphael Michel
2020-02-09 12:17:48 +01:00
parent 82e40ce664
commit 7acee9458d
2 changed files with 7 additions and 4 deletions

View File

@@ -388,4 +388,9 @@ class VoucherBulkForm(VoucherForm):
del data['codes']
objs.append(obj)
Voucher.objects.bulk_create(objs)
objs = []
for v in event.vouchers.filter(code__in=self.cleaned_data['codes']):
# We need to query them again as bulk_create does not fill in .pk values on databases
# other than PostgreSQL
objs.append(v)
return objs