We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
The voucher form doesn't show selected products
### Steps to reproduce the problem
1. Open Voucher form.
2. Set Discount type to specific product.
3. Choose the products you want.
4. Create the voucher.
5. Open the created voucher from the list of vouchers.

What happens is the products field goes blank.

### What I expected to happen
The chosen products must show up when viewing the created voucher.

**System information**
Operating system:  Ubuntu 16.04
Browser:  Chrome.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `saleor/dashboard/discount/forms.py`
Content:
```
1 from django import forms
2 from django.conf import settings
3 from django.urls import reverse_lazy
4 from django.utils.translation import pgettext_lazy
5 from django_countries import countries
6 from django_prices.forms import MoneyField
7 from mptt.forms import TreeNodeMultipleChoiceField
8 
9 from ...core.utils.taxes import ZERO_MONEY
10 from ...discount import DiscountValueType
11 from ...discount.models import Sale, Voucher
12 from ...discount.utils import generate_voucher_code
13 from ...product.models import Category, Product
14 from ..forms import AjaxSelect2MultipleChoiceField
15 
16 MinAmountSpent = MoneyField(
17     min_value=ZERO_MONEY, required=False,
18     currency=settings.DEFAULT_CURRENCY,
19     label=pgettext_lazy(
20         'Lowest value for order to be able to use the voucher',
21         'Apply only if the purchase value is greater than or equal to'))
22 
23 
24 class SaleForm(forms.ModelForm):
25     products = AjaxSelect2MultipleChoiceField(
26         queryset=Product.objects.all(),
27         fetch_data_url=reverse_lazy('dashboard:ajax-products'),
28         required=False,
29         label=pgettext_lazy('Discounted products', 'Discounted products'))
30 
31     class Meta:
32         model = Sale
33         exclude = []
34         labels = {
35             'name': pgettext_lazy(
36                 'Sale name',
37                 'Name'),
38             'type': pgettext_lazy(
39                 'Discount type',
40                 'Fixed or percentage'),
41             'start_date': pgettext_lazy(
42                 'Sale date restrictions',
43                 'Start date'),
44             'end_date': pgettext_lazy(
45                 'Sale date restrictions',
46                 'End date'),
47             'value': pgettext_lazy(
48                 'Percentage or fixed amount value',
49                 'Value'),
50             'categories': pgettext_lazy(
51                 'Discounted categories',
52                 'Discounted categories'),
53             'collections': pgettext_lazy(
54                 'Discounted collections',
55                 'Discounted collections')}
56 
57     def __init__(self, *args, **kwargs):
58         super().__init__(*args, **kwargs)
59         if self.instance.pk:
60             self.fields['products'].set_initial(self.instance.products.all())
61 
62     def clean(self):
63         cleaned_data = super().clean()
64         discount_type = cleaned_data['type']
65         value = cleaned_data['value']
66         if discount_type == DiscountValueType.PERCENTAGE and value > 100:
67             self.add_error('value', pgettext_lazy(
68                 'Sale (discount) error',
69                 'Sale cannot exceed 100%'))
70         products = cleaned_data.get('products')
71         categories = cleaned_data.get('categories')
72         collections = cleaned_data.get('collections')
73         if not any([products, categories, collections]):
74             raise forms.ValidationError(pgettext_lazy(
75                 'Sale (discount) error',
76                 'A single sale must point to at least one product, collection'
77                 'and/or category.'))
78         return cleaned_data
79 
80 
81 class VoucherForm(forms.ModelForm):
82 
83     class Meta:
84         model = Voucher
85         exclude = [
86             'min_amount_spent', 'countries', 'products', 'collections',
87             'categories', 'used']
88         labels = {
89             'type': pgettext_lazy(
90                 'Discount type',
91                 'Discount type'),
92             'name': pgettext_lazy(
93                 'Item name',
94                 'Name'),
95             'code': pgettext_lazy(
96                 'Coupon code',
97                 'Code'),
98             'usage_limit': pgettext_lazy(
99                 'Usage limit',
100                 'Usage limit'),
101             'start_date': pgettext_lazy(
102                 'Voucher date restrictions',
103                 'Start date'),
104             'end_date': pgettext_lazy(
105                 'Voucher date restrictions',
106                 'End date'),
107             'discount_value_type': pgettext_lazy(
108                 'Discount type of the voucher',
109                 'Discount type'),
110             'discount_value': pgettext_lazy(
111                 'Discount value of the voucher',
112                 'Discount value')}
113 
114     def __init__(self, *args, **kwargs):
115         initial = kwargs.get('initial', {})
116         instance = kwargs.get('instance')
117         if instance and instance.id is None and not initial.get('code'):
118             initial['code'] = generate_voucher_code()
119         kwargs['initial'] = initial
120         super().__init__(*args, **kwargs)
121 
122 
123 class ShippingVoucherForm(forms.ModelForm):
124     min_amount_spent = MinAmountSpent
125     countries = forms.MultipleChoiceField(
126         choices=countries,
127         required=False,
128         label=pgettext_lazy(
129             'Text above the dropdown of countries',
130             'Limit countries that voucher should apply to'))
131 
132     class Meta:
133         model = Voucher
134         fields = ['countries', 'min_amount_spent']
135 
136 
137 class ValueVoucherForm(forms.ModelForm):
138     min_amount_spent = MinAmountSpent
139 
140     class Meta:
141         model = Voucher
142         fields = ['min_amount_spent']
143 
144     def save(self, commit=True):
145         self.instance.category = None
146         self.instance.countries = []
147         self.instance.product = None
148         return super().save(commit)
149 
150 
151 class CommonVoucherForm(forms.ModelForm):
152     use_required_attribute = False
153     min_amount_spent = MinAmountSpent
154     apply_once_per_order = forms.BooleanField(
155         required=False,
156         label=pgettext_lazy(
157             'Field label, apply discount value only once per order',
158             'Only apply once per order'),
159         help_text=pgettext_lazy(
160             'Help text of checkbox for applying discount only once per order',
161             'If unchecked, discount value will be taken '
162             'off each suitable item in an order.'))
163 
164 
165 class ProductVoucherForm(CommonVoucherForm):
166     products = AjaxSelect2MultipleChoiceField(
167         queryset=Product.objects.all(),
168         fetch_data_url=reverse_lazy('dashboard:ajax-products'),
169         required=True,
170         label=pgettext_lazy('Product', 'Products'))
171 
172     class Meta:
173         model = Voucher
174         fields = ['products', 'apply_once_per_order']
175 
176 
177 class CollectionVoucherForm(CommonVoucherForm):
178 
179     class Meta:
180         model = Voucher
181         fields = ['collections', 'apply_once_per_order']
182         labels = {
183             'collections': pgettext_lazy(
184                 'Collections', 'Collections')}
185 
186     def __init__(self, *args, **kwargs):
187         super().__init__(*args, **kwargs)
188         self.fields['collections'].required = True
189 
190 
191 class CategoryVoucherForm(CommonVoucherForm):
192     categories = TreeNodeMultipleChoiceField(
193         queryset=Category.objects.all(),
194         required=True,
195         label=pgettext_lazy('Categories', 'Categories'))
196 
197     class Meta:
198         model = Voucher
199         fields = ['categories', 'apply_once_per_order']
200
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/saleor/dashboard/discount/forms.py b/saleor/dashboard/discount/forms.py
--- a/saleor/dashboard/discount/forms.py
+++ b/saleor/dashboard/discount/forms.py
@@ -173,6 +173,11 @@
         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):

{"golden_diff": "diff --git a/saleor/dashboard/discount/forms.py b/saleor/dashboard/discount/forms.py\n--- a/saleor/dashboard/discount/forms.py\n+++ b/saleor/dashboard/discount/forms.py\n@@ -173,6 +173,11 @@\n         model = Voucher\n         fields = ['products', 'apply_once_per_order']\n \n+    def __init__(self, *args, **kwargs):\n+        super().__init__(*args, **kwargs)\n+        if self.instance.pk:\n+            self.fields['products'].set_initial(self.instance.products.all())\n+\n \n class CollectionVoucherForm(CommonVoucherForm):\n", "issue": "The voucher form doesn't show selected products\n### Steps to reproduce the problem\r\n1. Open Voucher form.\r\n2. Set Discount type to specific product.\r\n3. Choose the products you want.\r\n4. Create the voucher.\r\n5. Open the created voucher from the list of vouchers.\r\n\r\nWhat happens is the products field goes blank.\r\n\r\n### What I expected to happen\r\nThe chosen products must show up when viewing the created voucher.\r\n\r\n**System information**\r\nOperating system:  Ubuntu 16.04\r\nBrowser:  Chrome.\r\n\n", "before_files": [{"content": "from django import forms\nfrom django.conf import settings\nfrom django.urls import reverse_lazy\nfrom django.utils.translation import pgettext_lazy\nfrom django_countries import countries\nfrom django_prices.forms import MoneyField\nfrom mptt.forms import TreeNodeMultipleChoiceField\n\nfrom ...core.utils.taxes import ZERO_MONEY\nfrom ...discount import DiscountValueType\nfrom ...discount.models import Sale, Voucher\nfrom ...discount.utils import generate_voucher_code\nfrom ...product.models import Category, Product\nfrom ..forms import AjaxSelect2MultipleChoiceField\n\nMinAmountSpent = MoneyField(\n    min_value=ZERO_MONEY, required=False,\n    currency=settings.DEFAULT_CURRENCY,\n    label=pgettext_lazy(\n        'Lowest value for order to be able to use the voucher',\n        'Apply only if the purchase value is greater than or equal to'))\n\n\nclass SaleForm(forms.ModelForm):\n    products = AjaxSelect2MultipleChoiceField(\n        queryset=Product.objects.all(),\n        fetch_data_url=reverse_lazy('dashboard:ajax-products'),\n        required=False,\n        label=pgettext_lazy('Discounted products', 'Discounted products'))\n\n    class Meta:\n        model = Sale\n        exclude = []\n        labels = {\n            'name': pgettext_lazy(\n                'Sale name',\n                'Name'),\n            'type': pgettext_lazy(\n                'Discount type',\n                'Fixed or percentage'),\n            'start_date': pgettext_lazy(\n                'Sale date restrictions',\n                'Start date'),\n            'end_date': pgettext_lazy(\n                'Sale date restrictions',\n                'End date'),\n            'value': pgettext_lazy(\n                'Percentage or fixed amount value',\n                'Value'),\n            'categories': pgettext_lazy(\n                'Discounted categories',\n                'Discounted categories'),\n            'collections': pgettext_lazy(\n                'Discounted collections',\n                'Discounted collections')}\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        if self.instance.pk:\n            self.fields['products'].set_initial(self.instance.products.all())\n\n    def clean(self):\n        cleaned_data = super().clean()\n        discount_type = cleaned_data['type']\n        value = cleaned_data['value']\n        if discount_type == DiscountValueType.PERCENTAGE and value > 100:\n            self.add_error('value', pgettext_lazy(\n                'Sale (discount) error',\n                'Sale cannot exceed 100%'))\n        products = cleaned_data.get('products')\n        categories = cleaned_data.get('categories')\n        collections = cleaned_data.get('collections')\n        if not any([products, categories, collections]):\n            raise forms.ValidationError(pgettext_lazy(\n                'Sale (discount) error',\n                'A single sale must point to at least one product, collection'\n                'and/or category.'))\n        return cleaned_data\n\n\nclass VoucherForm(forms.ModelForm):\n\n    class Meta:\n        model = Voucher\n        exclude = [\n            'min_amount_spent', 'countries', 'products', 'collections',\n            'categories', 'used']\n        labels = {\n            'type': pgettext_lazy(\n                'Discount type',\n                'Discount type'),\n            'name': pgettext_lazy(\n                'Item name',\n                'Name'),\n            'code': pgettext_lazy(\n                'Coupon code',\n                'Code'),\n            'usage_limit': pgettext_lazy(\n                'Usage limit',\n                'Usage limit'),\n            'start_date': pgettext_lazy(\n                'Voucher date restrictions',\n                'Start date'),\n            'end_date': pgettext_lazy(\n                'Voucher date restrictions',\n                'End date'),\n            'discount_value_type': pgettext_lazy(\n                'Discount type of the voucher',\n                'Discount type'),\n            'discount_value': pgettext_lazy(\n                'Discount value of the voucher',\n                'Discount value')}\n\n    def __init__(self, *args, **kwargs):\n        initial = kwargs.get('initial', {})\n        instance = kwargs.get('instance')\n        if instance and instance.id is None and not initial.get('code'):\n            initial['code'] = generate_voucher_code()\n        kwargs['initial'] = initial\n        super().__init__(*args, **kwargs)\n\n\nclass ShippingVoucherForm(forms.ModelForm):\n    min_amount_spent = MinAmountSpent\n    countries = forms.MultipleChoiceField(\n        choices=countries,\n        required=False,\n        label=pgettext_lazy(\n            'Text above the dropdown of countries',\n            'Limit countries that voucher should apply to'))\n\n    class Meta:\n        model = Voucher\n        fields = ['countries', 'min_amount_spent']\n\n\nclass ValueVoucherForm(forms.ModelForm):\n    min_amount_spent = MinAmountSpent\n\n    class Meta:\n        model = Voucher\n        fields = ['min_amount_spent']\n\n    def save(self, commit=True):\n        self.instance.category = None\n        self.instance.countries = []\n        self.instance.product = None\n        return super().save(commit)\n\n\nclass CommonVoucherForm(forms.ModelForm):\n    use_required_attribute = False\n    min_amount_spent = MinAmountSpent\n    apply_once_per_order = forms.BooleanField(\n        required=False,\n        label=pgettext_lazy(\n            'Field label, apply discount value only once per order',\n            'Only apply once per order'),\n        help_text=pgettext_lazy(\n            'Help text of checkbox for applying discount only once per order',\n            'If unchecked, discount value will be taken '\n            'off each suitable item in an order.'))\n\n\nclass ProductVoucherForm(CommonVoucherForm):\n    products = AjaxSelect2MultipleChoiceField(\n        queryset=Product.objects.all(),\n        fetch_data_url=reverse_lazy('dashboard:ajax-products'),\n        required=True,\n        label=pgettext_lazy('Product', 'Products'))\n\n    class Meta:\n        model = Voucher\n        fields = ['products', 'apply_once_per_order']\n\n\nclass CollectionVoucherForm(CommonVoucherForm):\n\n    class Meta:\n        model = Voucher\n        fields = ['collections', 'apply_once_per_order']\n        labels = {\n            'collections': pgettext_lazy(\n                'Collections', 'Collections')}\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.fields['collections'].required = True\n\n\nclass CategoryVoucherForm(CommonVoucherForm):\n    categories = TreeNodeMultipleChoiceField(\n        queryset=Category.objects.all(),\n        required=True,\n        label=pgettext_lazy('Categories', 'Categories'))\n\n    class Meta:\n        model = Voucher\n        fields = ['categories', 'apply_once_per_order']\n", "path": "saleor/dashboard/discount/forms.py"}], "after_files": [{"content": "from django import forms\nfrom django.conf import settings\nfrom django.urls import reverse_lazy\nfrom django.utils.translation import pgettext_lazy\nfrom django_countries import countries\nfrom django_prices.forms import MoneyField\nfrom mptt.forms import TreeNodeMultipleChoiceField\n\nfrom ...core.utils.taxes import ZERO_MONEY\nfrom ...discount import DiscountValueType\nfrom ...discount.models import Sale, Voucher\nfrom ...discount.utils import generate_voucher_code\nfrom ...product.models import Category, Product\nfrom ..forms import AjaxSelect2MultipleChoiceField\n\nMinAmountSpent = MoneyField(\n    min_value=ZERO_MONEY, required=False,\n    currency=settings.DEFAULT_CURRENCY,\n    label=pgettext_lazy(\n        'Lowest value for order to be able to use the voucher',\n        'Apply only if the purchase value is greater than or equal to'))\n\n\nclass SaleForm(forms.ModelForm):\n    products = AjaxSelect2MultipleChoiceField(\n        queryset=Product.objects.all(),\n        fetch_data_url=reverse_lazy('dashboard:ajax-products'),\n        required=False,\n        label=pgettext_lazy('Discounted products', 'Discounted products'))\n\n    class Meta:\n        model = Sale\n        exclude = []\n        labels = {\n            'name': pgettext_lazy(\n                'Sale name',\n                'Name'),\n            'type': pgettext_lazy(\n                'Discount type',\n                'Fixed or percentage'),\n            'start_date': pgettext_lazy(\n                'Sale date restrictions',\n                'Start date'),\n            'end_date': pgettext_lazy(\n                'Sale date restrictions',\n                'End date'),\n            'value': pgettext_lazy(\n                'Percentage or fixed amount value',\n                'Value'),\n            'categories': pgettext_lazy(\n                'Discounted categories',\n                'Discounted categories'),\n            'collections': pgettext_lazy(\n                'Discounted collections',\n                'Discounted collections')}\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        if self.instance.pk:\n            self.fields['products'].set_initial(self.instance.products.all())\n\n    def clean(self):\n        cleaned_data = super().clean()\n        discount_type = cleaned_data['type']\n        value = cleaned_data['value']\n        if discount_type == DiscountValueType.PERCENTAGE and value > 100:\n            self.add_error('value', pgettext_lazy(\n                'Sale (discount) error',\n                'Sale cannot exceed 100%'))\n        products = cleaned_data.get('products')\n        categories = cleaned_data.get('categories')\n        collections = cleaned_data.get('collections')\n        if not any([products, categories, collections]):\n            raise forms.ValidationError(pgettext_lazy(\n                'Sale (discount) error',\n                'A single sale must point to at least one product, collection'\n                'and/or category.'))\n        return cleaned_data\n\n\nclass VoucherForm(forms.ModelForm):\n\n    class Meta:\n        model = Voucher\n        exclude = [\n            'min_amount_spent', 'countries', 'products', 'collections',\n            'categories', 'used']\n        labels = {\n            'type': pgettext_lazy(\n                'Discount type',\n                'Discount type'),\n            'name': pgettext_lazy(\n                'Item name',\n                'Name'),\n            'code': pgettext_lazy(\n                'Coupon code',\n                'Code'),\n            'usage_limit': pgettext_lazy(\n                'Usage limit',\n                'Usage limit'),\n            'start_date': pgettext_lazy(\n                'Voucher date restrictions',\n                'Start date'),\n            'end_date': pgettext_lazy(\n                'Voucher date restrictions',\n                'End date'),\n            'discount_value_type': pgettext_lazy(\n                'Discount type of the voucher',\n                'Discount type'),\n            'discount_value': pgettext_lazy(\n                'Discount value of the voucher',\n                'Discount value')}\n\n    def __init__(self, *args, **kwargs):\n        initial = kwargs.get('initial', {})\n        instance = kwargs.get('instance')\n        if instance and instance.id is None and not initial.get('code'):\n            initial['code'] = generate_voucher_code()\n        kwargs['initial'] = initial\n        super().__init__(*args, **kwargs)\n\n\nclass ShippingVoucherForm(forms.ModelForm):\n    min_amount_spent = MinAmountSpent\n    countries = forms.MultipleChoiceField(\n        choices=countries,\n        required=False,\n        label=pgettext_lazy(\n            'Text above the dropdown of countries',\n            'Limit countries that voucher should apply to'))\n\n    class Meta:\n        model = Voucher\n        fields = ['countries', 'min_amount_spent']\n\n\nclass ValueVoucherForm(forms.ModelForm):\n    min_amount_spent = MinAmountSpent\n\n    class Meta:\n        model = Voucher\n        fields = ['min_amount_spent']\n\n    def save(self, commit=True):\n        self.instance.category = None\n        self.instance.countries = []\n        self.instance.product = None\n        return super().save(commit)\n\n\nclass CommonVoucherForm(forms.ModelForm):\n    use_required_attribute = False\n    min_amount_spent = MinAmountSpent\n    apply_once_per_order = forms.BooleanField(\n        required=False,\n        label=pgettext_lazy(\n            'Field label, apply discount value only once per order',\n            'Only apply once per order'),\n        help_text=pgettext_lazy(\n            'Help text of checkbox for applying discount only once per order',\n            'If unchecked, discount value will be taken '\n            'off each suitable item in an order.'))\n\n\nclass ProductVoucherForm(CommonVoucherForm):\n    products = AjaxSelect2MultipleChoiceField(\n        queryset=Product.objects.all(),\n        fetch_data_url=reverse_lazy('dashboard:ajax-products'),\n        required=True,\n        label=pgettext_lazy('Product', 'Products'))\n\n    class Meta:\n        model = Voucher\n        fields = ['products', 'apply_once_per_order']\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        if self.instance.pk:\n            self.fields['products'].set_initial(self.instance.products.all())\n\n\nclass CollectionVoucherForm(CommonVoucherForm):\n\n    class Meta:\n        model = Voucher\n        fields = ['collections', 'apply_once_per_order']\n        labels = {\n            'collections': pgettext_lazy(\n                'Collections', 'Collections')}\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.fields['collections'].required = True\n\n\nclass CategoryVoucherForm(CommonVoucherForm):\n    categories = TreeNodeMultipleChoiceField(\n        queryset=Category.objects.all(),\n        required=True,\n        label=pgettext_lazy('Categories', 'Categories'))\n\n    class Meta:\n        model = Voucher\n        fields = ['categories', 'apply_once_per_order']\n", "path": "saleor/dashboard/discount/forms.py"}]}