Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Migrations, permissions, expand ProductVariant form
Pacu2bcd1451ad121
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex 9397efb02e..21f0d75831 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -52,21 +52,6 @@ class ProductTypeSelectorForm(forms.Form):widget=forms.RadioSelect, empty_label=None)-class StockForm(forms.ModelForm):- class Meta:- model = ProductVariant- exclude = ['quantity_allocated']- labels = {- 'quantity': pgettext_lazy(- 'Integer number', 'Quantity'),- 'cost_price': pgettext_lazy(- 'Currency amount', 'Cost price')}-- def __init__(self, *args, **kwargs):- self.variant = kwargs.pop('variant')- super().__init__(*args, **kwargs)--class ProductTypeForm(forms.ModelForm):class Meta:model = ProductType@@ -255,11 +240,14 @@ class ProductVariantForm(forms.ModelForm, AttributesMixin):class Meta:model = ProductVariant- exclude = ['attributes', 'product', 'images', 'name']+ exclude = [+ 'attributes', 'product', 'images', 'name', 'quantity_allocated']labels = {'sku': pgettext_lazy('SKU', 'SKU'),'price_override': pgettext_lazy(- 'Override price', 'Override price')}+ 'Override price', 'Override price'),+ 'quantity': pgettext_lazy('Integer number', 'Quantity'),+ 'cost_price': pgettext_lazy('Currency amount', 'Cost price')}def __init__(self, *args, **kwargs):super().__init__(*args, **kwargs)diff --git a/saleor/data_feeds/google_merchant.py b/saleor/data_feeds/google_merchant.pyindex 15c68ba492..091b6422a3 100644--- a/saleor/data_feeds/google_merchant.py+++ b/saleor/data_feeds/google_merchant.py@@ -29,7 +29,7 @@ def get_feed_items():items = ProductVariant.objects.all()items = items.select_related('product')items = items.prefetch_related(- 'images', 'stock', 'product__category',+ 'images', 'product__category','product__images', 'product__product_type__product_attributes','product__product_type__variant_attributes')return itemsdiff --git a/saleor/order/migrations/0044_auto_20180329_0142.py b/saleor/order/migrations/0044_auto_20180329_0142.pynew file mode 100644index 0000000000..927a3ce2df--- /dev/null+++ b/saleor/order/migrations/0044_auto_20180329_0142.py@@ -0,0 +1,28 @@+# Generated by Django 2.0.3 on 2018-03-29 06:42++from django.db import migrations, models+import django.db.models.deletion+++class Migration(migrations.Migration):++ dependencies = [+ ('product', '0054_merge_20180320_1108'),+ ('order', '0043_auto_20180322_0655'),+ ]++ operations = [+ migrations.RemoveField(+ model_name='orderline',+ name='stock',+ ),+ migrations.RemoveField(+ model_name='orderline',+ name='stock_location',+ ),+ migrations.AddField(+ model_name='orderline',+ name='variant',+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='product.ProductVariant'),+ ),+ ]diff --git a/saleor/order/models.py b/saleor/order/models.pyindex b8497ba931..429d9aad1c 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -181,7 +181,7 @@ class OrderLine(models.Model):Product, blank=True, null=True, related_name='+',on_delete=models.SET_NULL)variant = models.ForeignKey(- ProductVariant, related_name='stock', on_delete=models.SET_NULL,+ ProductVariant, related_name='+', on_delete=models.SET_NULL,blank=True, null=True)product_name = models.CharField(max_length=128)product_sku = models.CharField(max_length=32)diff --git a/saleor/product/migrations/0055_auto_20180329_0142.py b/saleor/product/migrations/0055_auto_20180329_0142.pynew file mode 100644index 0000000000..4928efb8e4--- /dev/null+++ b/saleor/product/migrations/0055_auto_20180329_0142.py@@ -0,0 +1,50 @@+# Generated by Django 2.0.3 on 2018-03-29 06:42++from decimal import Decimal+import django.core.validators+from django.db import migrations, models+import django_prices.models+++class Migration(migrations.Migration):++ dependencies = [+ ('order', '0044_auto_20180329_0142'),+ ('product', '0054_merge_20180320_1108'),+ ]++ operations = [+ migrations.AlterUniqueTogether(+ name='stock',+ unique_together=set(),+ ),+ migrations.RemoveField(+ model_name='stock',+ name='location',+ ),+ migrations.RemoveField(+ model_name='stock',+ name='variant',+ ),+ migrations.AddField(+ model_name='productvariant',+ name='cost_price',+ field=django_prices.models.MoneyField(blank=True, currency='USD', decimal_places=2, max_digits=12, null=True),+ ),+ migrations.AddField(+ model_name='productvariant',+ name='quantity',+ field=models.IntegerField(default=Decimal('1'), validators=[django.core.validators.MinValueValidator(0)]),+ ),+ migrations.AddField(+ model_name='productvariant',+ name='quantity_allocated',+ field=models.IntegerField(default=Decimal('0'), validators=[django.core.validators.MinValueValidator(0)]),+ ),+ migrations.DeleteModel(+ name='Stock',+ ),+ migrations.DeleteModel(+ name='StockLocation',+ ),+ ]diff --git a/templates/dashboard/base.html b/templates/dashboard/base.htmlindex 38cc92ea33..91c95fc8ab 100644--- a/templates/dashboard/base.html+++ b/templates/dashboard/base.html@@ -96,7 +96,7 @@{% trans "Home" context "Dashboard homepage" %}</a></li>- {% if perms.product.view_product or perms.product.view_category or perms.product.view_stock %}+ {% if perms.product.view_product or perms.product.view_category %}<li class="side-nav-section" id="first"><p>{% trans "Catalogue" context "Dashboard catalogue" %}diff --git a/tests/conftest.py b/tests/conftest.pyindex 0b3a134fd3..bc1251d587 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -202,16 +202,6 @@ def permission_edit_category():return Permission.objects.get(codename='edit_category')-def permission_view_stock():- return Permission.objects.get(codename='view_stock')---def permission_edit_stock():- return Permission.objects.get(codename='edit_stock')--@pytest.fixturedef permission_view_sale():return Permission.objects.get(codename='view_sale')