fix
This commit is contained in:
@@ -7,7 +7,7 @@ class AdminProductListSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Product
|
||||
fields = [
|
||||
'id', 'name_uz', 'name_ru', 'image', 'category', 'price', 'description_uz', 'description_ru', 'unity', 'tg_id', 'code', 'article', 'quantity_left'
|
||||
'id', 'name_uz', 'name_ru', 'image', 'category', 'price', 'description_uz', 'description_ru', 'unity', 'tg_id', 'code', 'article', 'quantity_left', 'min_quantity'
|
||||
]
|
||||
|
||||
def get_category(self, obj):
|
||||
@@ -21,7 +21,7 @@ class ProductSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Product
|
||||
fields = [
|
||||
'name_uz', 'name_ru', 'image', 'category', 'price', 'description_uz', 'description_ru', 'unity', 'tg_id', 'code', 'article', 'quantity_left'
|
||||
'name_uz', 'name_ru', 'image', 'category', 'price', 'description_uz', 'description_ru', 'unity', 'tg_id', 'code', 'article', 'quantity_left', 'min_quantity'
|
||||
]
|
||||
extra_kwargs = {
|
||||
'image': {'required':False},
|
||||
|
||||
18
core/apps/orders/migrations/0009_alter_orderitem_quantity.py
Normal file
18
core/apps/orders/migrations/0009_alter_orderitem_quantity.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2 on 2025-09-06 17:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('orders', '0008_alter_order_payment_type'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='orderitem',
|
||||
name='quantity',
|
||||
field=models.FloatField(),
|
||||
),
|
||||
]
|
||||
@@ -37,7 +37,7 @@ class Order(BaseModel):
|
||||
|
||||
class OrderItem(BaseModel):
|
||||
order = models.ForeignKey(Order, on_delete=models.CASCADE, related_name='items')
|
||||
quantity = models.PositiveIntegerField()
|
||||
quantity = models.FloatField()
|
||||
price = models.PositiveBigIntegerField()
|
||||
product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='items', null=True)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from core.apps.orders.tasks.order_item import send_orders_to_tg_bot
|
||||
|
||||
class OrderItemCreateSerializer(serializers.Serializer):
|
||||
product_id = serializers.UUIDField()
|
||||
quantity = serializers.IntegerField()
|
||||
quantity = serializers.FloatField()
|
||||
|
||||
def validate(self, data):
|
||||
product = Product.objects.filter(id=data['product_id']).first()
|
||||
|
||||
18
core/apps/products/migrations/0010_product_min_quantity.py
Normal file
18
core/apps/products/migrations/0010_product_min_quantity.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2 on 2025-09-06 17:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('products', '0009_alter_category_options_category_order'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='product',
|
||||
name='min_quantity',
|
||||
field=models.FloatField(null=True),
|
||||
),
|
||||
]
|
||||
@@ -26,6 +26,7 @@ class Product(BaseModel):
|
||||
article = models.CharField(max_length=200, null=True, blank=True, unique=True)
|
||||
code = models.CharField(max_length=200, null=True, blank=True)
|
||||
quantity_left = models.PositiveBigIntegerField(default=0)
|
||||
min_quantity = models.FloatField(null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@@ -11,7 +11,7 @@ class ProductListSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Product
|
||||
fields = [
|
||||
'id', 'name', 'image', 'price', 'description', 'liked', 'unity',
|
||||
'id', 'name', 'image', 'price', 'description', 'liked', 'unity', 'min_quantity'
|
||||
]
|
||||
|
||||
def get_liked(self, obj):
|
||||
|
||||
Reference in New Issue
Block a user