Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Allow to add only available products

Anna Siwik44ba7a26d3eb
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
index b9f380f718..465a6b30ce 100644
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -17,7 +17,7 @@ from ...order.models import DeliveryGroup, Order, OrderLine, OrderNote
from ...order.utils import (
add_item_to_delivery_group, cancel_order, cancel_delivery_group,
change_order_line_quantity, merge_duplicated_lines)
-from ...product.models import ProductVariant, Stock
+from ...product.models import Product, ProductVariant, Stock
class OrderNoteForm(forms.ModelForm):
@@ -356,7 +356,8 @@ class ChangeStockForm(forms.ModelForm):
class AddDeliveryGroupItemForm(forms.Form):
variant = AjaxSelect2ChoiceField(
- queryset=ProductVariant.objects.all(),
+ queryset=ProductVariant.objects.filter(
+ product__in=Product.objects.get_available_products()),
fetch_data_url=reverse_lazy('dashboard:ajax-variants'))
quantity = QuantityField(
label=pgettext_lazy('Variant quantity form label', 'Quantity'),