add some new fields to sale item
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import string
|
||||
import random
|
||||
from apps.authentication.models import User, Organization
|
||||
from apps.pos_device.models import POSFreeProducts
|
||||
from apps.product import models as product_models
|
||||
from apps.pos_device.models import Device
|
||||
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)
|
||||
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)
|
||||
transactions_number = models.PositiveBigIntegerField(default=0)
|
||||
status_type = (
|
||||
@@ -142,12 +148,18 @@ class InventoryQuotaSaleItem(BaseModel):
|
||||
related_name='sale_items',
|
||||
null=True
|
||||
)
|
||||
product = models.ForeignKey(
|
||||
gov_product = models.ForeignKey(
|
||||
product_models.Product,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='sale_items',
|
||||
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)
|
||||
name = 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_pre_sale = models.BooleanField(default=False)
|
||||
|
||||
@property
|
||||
def product(self):
|
||||
return self.gov_product or self.free_product
|
||||
|
||||
def __str__(self):
|
||||
return f'Item {self.product} - {self.weight} Kg - {self.total_price}'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user