add: add new invalid product model and create, list api added
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from .inventory import *
|
||||
from .wherehouse import *
|
||||
from .stock_movemend import *
|
||||
from .stock_movemend import *
|
||||
from .invalid_product import *
|
||||
43
core/apps/wherehouse/models/invalid_product.py
Normal file
43
core/apps/wherehouse/models/invalid_product.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from django.db import models
|
||||
|
||||
# shared
|
||||
from core.apps.shared.models import BaseModel
|
||||
# wherehouse
|
||||
from core.apps.wherehouse.models import WhereHouse, Inventory
|
||||
# projects
|
||||
from core.apps.projects.models import ProjectFolder, EstimateWork
|
||||
# accounts
|
||||
from core.apps.accounts.models import User
|
||||
|
||||
|
||||
class InvalidProduct(BaseModel):
|
||||
STATUS = (
|
||||
('BROKEN', 'singan'),
|
||||
('LOST', 'yoqolgan'),
|
||||
('OTHER', 'boshqa'),
|
||||
)
|
||||
|
||||
# relationship
|
||||
inventory = models.ForeignKey(Inventory, on_delete=models.CASCADE, related_name='invalid_products')
|
||||
project_folder = models.ForeignKey(
|
||||
ProjectFolder, on_delete=models.CASCADE, related_name='invalid_products'
|
||||
)
|
||||
witnesses = models.ManyToManyField(User, related_name='invalid_products')
|
||||
work = models.ForeignKey(
|
||||
EstimateWork, on_delete=models.SET_NULL, null=True, blank=True, related_name='invalid_products'
|
||||
)
|
||||
# required
|
||||
amount = models.PositiveIntegerField()
|
||||
status = models.CharField(max_length=20, choices=STATUS, default='other')
|
||||
# optional
|
||||
created_date = models.DateField(null=True, blank=True)
|
||||
expiry_date = models.DateField(null=True, blank=True)
|
||||
comment = models.DateField(null=True, blank=True)
|
||||
file = models.FileField(null=True, blank=True, upload_to='invalid_product/files/')
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.amount} ta maxsulot yaroqsiz'
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'yaroqsiz maxsulot'
|
||||
verbose_name_plural = 'yaroqsiz maxsulotlar'
|
||||
@@ -26,6 +26,7 @@ class Inventory(BaseModel):
|
||||
Project, on_delete=models.SET_NULL, null=True, blank=True,
|
||||
related_name='inventories'
|
||||
)
|
||||
is_invalid = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.product} in {self.wherehouse}'
|
||||
|
||||
Reference in New Issue
Block a user