From d4825d00fb47a5a58dc567cbf5846cd129a8f1d1 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 20 May 2022 16:09:47 +0200 Subject: [PATCH] Fix copying variations when copying items --- src/pretix/control/forms/item.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pretix/control/forms/item.py b/src/pretix/control/forms/item.py index 2ba9cea8e1..08ce92f4e2 100644 --- a/src/pretix/control/forms/item.py +++ b/src/pretix/control/forms/item.py @@ -32,6 +32,7 @@ # Unless required by applicable law or agreed to in writing, software distributed under the Apache License 2.0 is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under the License. +import copy import os from decimal import Decimal from urllib.parse import urlencode @@ -423,9 +424,10 @@ class ItemCreateForm(I18nModelForm): if self.cleaned_data.get('has_variations'): if self.cleaned_data.get('copy_from') and self.cleaned_data.get('copy_from').has_variations: for variation in self.cleaned_data['copy_from'].variations.all(): - ItemVariation.objects.create(item=instance, value=variation.value, active=variation.active, - position=variation.position, default_price=variation.default_price, - description=variation.description, original_price=variation.original_price) + v = copy.copy(variation) + v.pk = None + v.item = instance + v.save() else: ItemVariation.objects.create( item=instance, value=__('Standard')