Skip to content

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

Change references to field of Stock Location model

Mira Szewczyk1cdf3255a0e7
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index 4845e56cc4..4e4c377875 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -63,7 +63,7 @@ def create_product(**kwargs):
def create_stock(variant, **kwargs):
default_location = StockLocation.objects.get_or_create(
- location=STOCK_LOCATION)[0]
+ name=STOCK_LOCATION)[0]
defaults = {
'variant': variant,
'location': default_location,
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 334f4ca61f..9ea0858cd4 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -252,7 +252,7 @@ class DeliveryGroup(models.Model, ItemSet):
product_sku=product_variant.sku,
unit_price_gross=price.gross,
stock=stock,
- stock_location=stock.location.location if stock else None)
+ stock_location=stock.location.name if stock else None)
if stock:
# allocate quantity to avoid overselling
Stock.objects.allocate_stock(stock, quantity)
diff --git a/saleor/product/models/base.py b/saleor/product/models/base.py
index 1f8e0daabc..384e176ac8 100644
--- a/saleor/product/models/base.py
+++ b/saleor/product/models/base.py
@@ -246,7 +246,7 @@ class StockLocation(models.Model):
pgettext_lazy('Stock item field', 'location'), max_length=100)
def __str__(self):
- return self.location
+ return self.name
class StockManager(models.Manager):
diff --git a/templates/dashboard/product/stock_locations/form.html b/templates/dashboard/product/stock_locations/form.html
index e1474a35b3..0d0103517d 100644
--- a/templates/dashboard/product/stock_locations/form.html
+++ b/templates/dashboard/product/stock_locations/form.html
@@ -41,7 +41,7 @@
<div class="col s12 l4">
<div class="row">
- {{ form.location|materializecss:"input-field s12" }}
+ {{ form.name|materializecss:"input-field s12" }}
</div>
</div>
diff --git a/tests/conftest.py b/tests/conftest.py
index c6fa240075..e479443605 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -92,9 +92,9 @@ def product_in_stock(db): # pylint: disable=W0613
product = Product.objects.create(
name='Test product', price=10, weight=1)
variant = ProductVariant.objects.create(product=product, sku='123')
- warehouse_1 = StockLocation.objects.create(location='Warehouse 1')
- warehouse_2 = StockLocation.objects.create(location='Warehouse 2')
- warehouse_3 = StockLocation.objects.create(location='Warehouse 3')
+ warehouse_1 = StockLocation.objects.create(name='Warehouse 1')
+ warehouse_2 = StockLocation.objects.create(name='Warehouse 2')
+ warehouse_3 = StockLocation.objects.create(name='Warehouse 3')
Stock.objects.create(
variant=variant, cost_price=1, quantity=5, quantity_allocated=5,
location=warehouse_1)