forked from CGM_Public/pretix_original
Fix copying variations when copying items
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
# Unless required by applicable law or agreed to in writing, software distributed under the Apache License 2.0 is
|
# 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
|
# 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.
|
# License for the specific language governing permissions and limitations under the License.
|
||||||
|
import copy
|
||||||
import os
|
import os
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
@@ -423,9 +424,10 @@ class ItemCreateForm(I18nModelForm):
|
|||||||
if self.cleaned_data.get('has_variations'):
|
if self.cleaned_data.get('has_variations'):
|
||||||
if self.cleaned_data.get('copy_from') and self.cleaned_data.get('copy_from').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():
|
for variation in self.cleaned_data['copy_from'].variations.all():
|
||||||
ItemVariation.objects.create(item=instance, value=variation.value, active=variation.active,
|
v = copy.copy(variation)
|
||||||
position=variation.position, default_price=variation.default_price,
|
v.pk = None
|
||||||
description=variation.description, original_price=variation.original_price)
|
v.item = instance
|
||||||
|
v.save()
|
||||||
else:
|
else:
|
||||||
ItemVariation.objects.create(
|
ItemVariation.objects.create(
|
||||||
item=instance, value=__('Standard')
|
item=instance, value=__('Standard')
|
||||||
|
|||||||
Reference in New Issue
Block a user