Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add StockLocation model
Mira Szewczyke247fdd768c0
diff --git a/saleor/product/migrations/0013_auto_20161205_0920.py b/saleor/product/migrations/0013_auto_20161205_0920.pynew file mode 100644index 0000000000..5c8f82a7a6--- /dev/null+++ b/saleor/product/migrations/0013_auto_20161205_0920.py@@ -0,0 +1,28 @@+# -*- coding: utf-8 -*-+# Generated by Django 1.10.3 on 2016-12-05 15:20+from __future__ import unicode_literals++from django.db import migrations, models+import django.db.models.deletion+++class Migration(migrations.Migration):++ dependencies = [+ ('product', '0012_auto_20160218_0812'),+ ]++ operations = [+ migrations.CreateModel(+ name='StockLocation',+ fields=[+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),+ ('location', models.CharField(max_length=100, verbose_name='location')),+ ],+ ),+ migrations.AlterField(+ model_name='stock',+ name='location',+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='product.StockLocation'),+ ),+ ]diff --git a/saleor/product/models/base.py b/saleor/product/models/base.pyindex be98a4bc03..d7c02dc531 100644--- a/saleor/product/models/base.py+++ b/saleor/product/models/base.py@@ -240,6 +240,15 @@ class ProductVariant(models.Model, Item):return stock.cost_price+@python_2_unicode_compatible+class StockLocation(models.Model):+ location = models.CharField(+ pgettext_lazy('Stock item field', 'location'), max_length=100)++ def __str__(self):+ return self.location++class StockManager(models.Manager):def allocate_stock(self, stock, quantity):@@ -261,8 +270,7 @@ class Stock(models.Model):variant = models.ForeignKey(ProductVariant, related_name='stock',verbose_name=pgettext_lazy('Stock item field', 'variant'))- location = models.CharField(- pgettext_lazy('Stock item field', 'location'), max_length=100)+ location = models.ForeignKey(StockLocation)quantity = models.IntegerField(pgettext_lazy('Stock item field', 'quantity'),validators=[MinValueValidator(0)], default=Decimal(1))