Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove field quantity and quantity allocated from ProductVariant
Mira Szewczykb30eaa9deda9
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex c287bae691..a279f89231 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -3349,7 +3349,6 @@ type ProductVariant implements Node {sku: String!product: Product!trackInventory: Boolean!- quantityAllocated: Int!weight: WeightprivateMeta: [MetaStore]!meta: [MetaStore]!diff --git a/saleor/product/migrations/0111_auto_20191129_0506.py b/saleor/product/migrations/0111_auto_20191129_0506.pynew file mode 100644index 0000000000..3a425a03af--- /dev/null+++ b/saleor/product/migrations/0111_auto_20191129_0506.py@@ -0,0 +1,13 @@+# Generated by Django 2.2.6 on 2019-11-29 11:06++from django.db import migrations+++class Migration(migrations.Migration):++ dependencies = [("product", "0110_auto_20191108_0340")]++ operations = [+ migrations.RemoveField(model_name="productvariant", name="quantity"),+ migrations.RemoveField(model_name="productvariant", name="quantity_allocated"),+ ]diff --git a/saleor/product/models.py b/saleor/product/models.pyindex 222821b9b2..2643ee8a54 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -1,11 +1,9 @@-from decimal import Decimalfrom typing import TYPE_CHECKING, Iterable, Optional, Unionfrom uuid import uuid4from django.conf import settingsfrom django.contrib.postgres.aggregates import StringAggfrom django.contrib.postgres.fields import JSONField-from django.core.validators import MinValueValidatorfrom django.db import modelsfrom django.db.models import Case, Count, F, FilteredRelation, Q, Whenfrom django.urls import reverse@@ -441,12 +439,7 @@ class ProductVariant(ModelWithMetadata):)images = models.ManyToManyField("ProductImage", through="VariantImage")track_inventory = models.BooleanField(default=True)- quantity = models.IntegerField(- validators=[MinValueValidator(0)], default=Decimal(1)- )- quantity_allocated = models.IntegerField(- validators=[MinValueValidator(0)], default=Decimal(0)- )+cost_price_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,@@ -467,10 +460,6 @@ class ProductVariant(ModelWithMetadata):def __str__(self) -> str:return self.name or self.sku- @property- def quantity_available(self) -> int:- return max(self.quantity - self.quantity_allocated, 0)-@propertydef is_visible(self) -> bool:return self.product.is_visible