Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use display_variant method in str method of product variant
Mira Szewczykb0cf6d1e5434
diff --git a/saleor/product/forms.py b/saleor/product/forms.pyindex 96831d83f6..4db1ce4f4c 100644--- a/saleor/product/forms.py+++ b/saleor/product/forms.py@@ -4,6 +4,7 @@ import jsonfrom django import formsfrom django.template.loader import render_to_string+from django.utils.encoding import smart_textfrom django.utils.translation import pgettext_lazyfrom django_prices.templatetags.prices_i18n import gross@@ -15,7 +16,7 @@ class VariantChoiceField(forms.ModelChoiceField):def label_from_instance(self, obj):attributes = obj.product.product_class.variant_attributes.all()- variant_label = obj.display_variant(attributes)+ variant_label = smart_text(obj)label = '%(variant_label)s - %(price)s' % {'variant_label': variant_label,'price': gross(obj.get_price(discounts=self.discounts))}diff --git a/saleor/product/models/base.py b/saleor/product/models/base.pyindex 22f6ffcac5..c5bdaea4b0 100644--- a/saleor/product/models/base.py+++ b/saleor/product/models/base.py@@ -205,7 +205,7 @@ class ProductVariant(models.Model, Item):app_label = 'product'def __str__(self):- return self.name or self.sku+ return self.name or self.display_variant()def get_weight(self):return self.weight_override or self.product.weight@@ -265,7 +265,7 @@ class ProductVariant(models.Model, Item):smart_text(value))for (key, value) in six.iteritems(values)])else:- return smart_text(self)+ return smart_text(self.sku)def display_product(self, attributes=None):return '%s (%s)' % (smart_text(self.product),