From f3dbbce39ce2d4ca93489ce3453e5037a2b4f5cb Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 30 Mar 2026 17:36:36 +0200 Subject: [PATCH] Order change form: Allow to add multiple identical positions (Z#23227479) --- src/pretix/control/forms/orders.py | 8 ++++++++ .../templates/pretixcontrol/order/change.html | 2 ++ src/pretix/control/views/orders.py | 13 +++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/pretix/control/forms/orders.py b/src/pretix/control/forms/orders.py index 4fc22a5903..4df41eaf44 100644 --- a/src/pretix/control/forms/orders.py +++ b/src/pretix/control/forms/orders.py @@ -331,6 +331,10 @@ class OtherOperationsForm(forms.Form): class OrderPositionAddForm(forms.Form): + count = forms.IntegerField( + label=_('Number of products to add'), + initial=1, + ) itemvar = forms.ChoiceField( label=_('Product') ) @@ -432,6 +436,10 @@ class OrderPositionAddForm(forms.Form): d['used_membership'] = [m for m in self.memberships if str(m.pk) == d['used_membership']][0] else: d['used_membership'] = None + if d.get("count", 1) and d.get("seat"): + raise ValidationError({ + "seat": _("You can not choose a seat when adding multiple products at once.") + }) return d diff --git a/src/pretix/control/templates/pretixcontrol/order/change.html b/src/pretix/control/templates/pretixcontrol/order/change.html index e77c792e28..a4dd0c83a7 100644 --- a/src/pretix/control/templates/pretixcontrol/order/change.html +++ b/src/pretix/control/templates/pretixcontrol/order/change.html @@ -329,6 +329,7 @@ {{ add_form.custom_error }} {% endif %} + {% bootstrap_field add_form.count layout="control" %} {% bootstrap_field add_form.itemvar layout="control" %} {% bootstrap_field add_form.price addon_after=request.event.currency layout="control" %} {% if add_form.addon_to %} @@ -364,6 +365,7 @@
+ {% bootstrap_field add_position_formset.empty_form.count layout="control" %} {% bootstrap_field add_position_formset.empty_form.itemvar layout="control" %} {% bootstrap_field add_position_formset.empty_form.price addon_after=request.event.currency layout="control" %} {% if add_position_formset.empty_form.addon_to %} diff --git a/src/pretix/control/views/orders.py b/src/pretix/control/views/orders.py index ea6ddfe349..5d60911009 100644 --- a/src/pretix/control/views/orders.py +++ b/src/pretix/control/views/orders.py @@ -2059,12 +2059,13 @@ class OrderChange(OrderView): else: variation = None try: - ocm.add_position(item, variation, - f.cleaned_data['price'], - f.cleaned_data.get('addon_to'), - f.cleaned_data.get('subevent'), - f.cleaned_data.get('seat'), - f.cleaned_data.get('used_membership')) + for i in range(f.cleaned_data.get("count", 1)): + ocm.add_position(item, variation, + f.cleaned_data['price'], + f.cleaned_data.get('addon_to'), + f.cleaned_data.get('subevent'), + f.cleaned_data.get('seat'), + f.cleaned_data.get('used_membership')) except OrderError as e: f.custom_error = str(e) return False