Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Create stock location in populatedb command
Mira Szewczykf45b568e38c3
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex cd2e753d40..4845e56cc4 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -13,7 +13,7 @@ from prices import Pricefrom ...shipping.models import ShippingMethod, ANY_COUNTRYfrom ...order.models import DeliveryGroup, Order, OrderedItem, Paymentfrom ...product.models import (Category, Product, ProductImage,- ProductVariant, Stock)+ ProductVariant, Stock, StockLocation)from ...userprofile.models import Address, Userfake = Factory.create()@@ -62,9 +62,11 @@ def create_product(**kwargs):def create_stock(variant, **kwargs):+ default_location = StockLocation.objects.get_or_create(+ location=STOCK_LOCATION)[0]defaults = {'variant': variant,- 'location': STOCK_LOCATION,+ 'location': default_location,'quantity': fake.random_int(1, 50)}defaults.update(kwargs)return Stock.objects.create(**defaults)