Skip to content

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

Store variants in OrderItems

Marcin Gębala6371cf736684
diff --git a/saleor/order/migrations/0002_auto_20150715_0813.py b/saleor/order/migrations/0002_auto_20150715_0813.py
new file mode 100644
index 0000000000..e7238f294e
--- /dev/null
+++ b/saleor/order/migrations/0002_auto_20150715_0813.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('order', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='ordereditem',
+ name='product',
+ field=models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.SET_NULL, verbose_name='product', blank=True, to='product.ProductVariant', null=True),
+ ),
+ ]
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 9a7ae7f82b..5db7248d41 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -20,7 +20,7 @@ from prices import Price
from satchless.item import ItemSet, ItemLine
from ..core.utils import build_absolute_uri
-from ..product.models import Product
+from ..product.models import Product, ProductVariant
from ..userprofile.models import Address, User
from ..delivery import get_delivery
@@ -205,7 +205,7 @@ class DeliveryGroup(models.Model, ItemSet):
product_variant = item_line.product
price = item_line.get_price_per_item()
self.items.create(
- product=product_variant.product,
+ product=product_variant,
quantity=item_line.get_quantity(),
unit_price_net=price.net,
product_name=smart_text(product_variant),
@@ -261,7 +261,7 @@ class OrderedItem(models.Model, ItemLine):
delivery_group = models.ForeignKey(
DeliveryGroup, related_name='items', editable=False)
product = models.ForeignKey(
- Product, blank=True, null=True, related_name='+',
+ ProductVariant, blank=True, null=True, related_name='+',
on_delete=models.SET_NULL,
verbose_name=pgettext_lazy('OrderedItem field', 'product'))
product_name = models.CharField(