Skip to content

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

Fix product listing not showing in the voucher form

NyanKiyoshi7d94d8047de8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b34dbe1c9..5a294d0e94 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Remove unused decorator - #4036 by @maarcingebala
- Overall improvement of the GraphQL performances, especially on single nodes - #3968 @NyanKiyoshi
- Remove unnecessary dedents from GraphQL schema so new Playground can work - #4045 by @salwator
+- Fix the product listing not showing in the voucher when there were products selected - #4062 by @NyanKiyoshi
## 2.5.0
diff --git a/saleor/dashboard/discount/forms.py b/saleor/dashboard/discount/forms.py
index bb0af42864..e9b65c2b4a 100644
--- a/saleor/dashboard/discount/forms.py
+++ b/saleor/dashboard/discount/forms.py
@@ -173,6 +173,11 @@ class ProductVoucherForm(CommonVoucherForm):
model = Voucher
fields = ['products', 'apply_once_per_order']
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ if self.instance.pk:
+ self.fields['products'].set_initial(self.instance.products.all())
+
class CollectionVoucherForm(CommonVoucherForm):