add some new fields to sale item
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-09-22 06:24
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('pos_device', '0074_stakeholders_default'),
|
||||||
|
('warehouse', '0031_inventoryquotasaleitem_delivery_type_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='inventoryquotasaleitem',
|
||||||
|
old_name='product',
|
||||||
|
new_name='gov_product',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='inventoryquotasaleitem',
|
||||||
|
name='free_product',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sale_items', to='pos_device.posfreeproducts'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='inventoryquotasaletransaction',
|
||||||
|
name='product_type',
|
||||||
|
field=models.CharField(choices=[('gov', 'government'), ('free', 'free')], default='free', max_length=20),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import string
|
import string
|
||||||
import random
|
import random
|
||||||
from apps.authentication.models import User, Organization
|
from apps.authentication.models import User, Organization
|
||||||
|
from apps.pos_device.models import POSFreeProducts
|
||||||
from apps.product import models as product_models
|
from apps.product import models as product_models
|
||||||
from apps.pos_device.models import Device
|
from apps.pos_device.models import Device
|
||||||
from apps.herd.models import Rancher
|
from apps.herd.models import Rancher
|
||||||
@@ -100,6 +101,11 @@ class InventoryQuotaSaleTransaction(BaseModel):
|
|||||||
)
|
)
|
||||||
price_type = models.CharField(choices=type_of_price, max_length=50, null=True)
|
price_type = models.CharField(choices=type_of_price, max_length=50, null=True)
|
||||||
description = models.TextField(blank=True, null=True)
|
description = models.TextField(blank=True, null=True)
|
||||||
|
product_type_choices = (
|
||||||
|
('gov', 'government'),
|
||||||
|
('free', 'free'),
|
||||||
|
)
|
||||||
|
product_type = models.CharField(max_length=20, choices=product_type_choices, default='free')
|
||||||
herd_owners_number = models.PositiveBigIntegerField(default=0)
|
herd_owners_number = models.PositiveBigIntegerField(default=0)
|
||||||
transactions_number = models.PositiveBigIntegerField(default=0)
|
transactions_number = models.PositiveBigIntegerField(default=0)
|
||||||
status_type = (
|
status_type = (
|
||||||
@@ -142,12 +148,18 @@ class InventoryQuotaSaleItem(BaseModel):
|
|||||||
related_name='sale_items',
|
related_name='sale_items',
|
||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
product = models.ForeignKey(
|
gov_product = models.ForeignKey(
|
||||||
product_models.Product,
|
product_models.Product,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
related_name='sale_items',
|
related_name='sale_items',
|
||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
|
free_product = models.ForeignKey(
|
||||||
|
POSFreeProducts,
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name='sale_items',
|
||||||
|
null=True
|
||||||
|
)
|
||||||
image = models.CharField(max_length=150, null=True)
|
image = models.CharField(max_length=150, null=True)
|
||||||
name = models.CharField(max_length=150, null=True)
|
name = models.CharField(max_length=150, null=True)
|
||||||
price_type = models.CharField(max_length=150, null=True)
|
price_type = models.CharField(max_length=150, null=True)
|
||||||
@@ -159,6 +171,10 @@ class InventoryQuotaSaleItem(BaseModel):
|
|||||||
is_extra = models.BooleanField(default=False)
|
is_extra = models.BooleanField(default=False)
|
||||||
is_pre_sale = models.BooleanField(default=False)
|
is_pre_sale = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def product(self):
|
||||||
|
return self.gov_product or self.free_product
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'Item {self.product} - {self.weight} Kg - {self.total_price}'
|
return f'Item {self.product} - {self.weight} Kg - {self.total_price}'
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,8 @@ class InventoryQuotaSaleItemSerializer(serializers.ModelSerializer):
|
|||||||
fields = [
|
fields = [
|
||||||
'id',
|
'id',
|
||||||
"transaction",
|
"transaction",
|
||||||
"product",
|
"gov_product",
|
||||||
|
"free_product",
|
||||||
"product_name",
|
"product_name",
|
||||||
"image",
|
"image",
|
||||||
"name",
|
"name",
|
||||||
|
|||||||
Reference in New Issue
Block a user