Skip to content

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

Remove field quantity and quantity allocated from ProductVariant

Mira Szewczykb30eaa9deda9
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 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: Weight
privateMeta: [MetaStore]!
meta: [MetaStore]!
diff --git a/saleor/product/migrations/0111_auto_20191129_0506.py b/saleor/product/migrations/0111_auto_20191129_0506.py
new file mode 100644
index 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.py
index 222821b9b2..2643ee8a54 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -1,11 +1,9 @@
-from decimal import Decimal
from typing import TYPE_CHECKING, Iterable, Optional, Union
from uuid import uuid4
from django.conf import settings
from django.contrib.postgres.aggregates import StringAgg
from django.contrib.postgres.fields import JSONField
-from django.core.validators import MinValueValidator
from django.db import models
from django.db.models import Case, Count, F, FilteredRelation, Q, When
from 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)
-
@property
def is_visible(self) -> bool:
return self.product.is_visible