add: add stock movemend models, api, admins
This commit is contained in:
@@ -2,32 +2,63 @@ from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.apps.shared.models import BaseModel
|
||||
from core.apps.wherehouse.models.wherehouse import WhereHouse
|
||||
from core.apps.products.models.product import Product
|
||||
# wherehouse
|
||||
from core.apps.wherehouse.models import WhereHouse, Inventory
|
||||
# accounts
|
||||
from core.apps.accounts.models import User
|
||||
# projects
|
||||
from core.apps.projects.models import Project, ProjectFolder
|
||||
|
||||
|
||||
class StockMovemend(BaseModel):
|
||||
TYPE = (
|
||||
('IN', 'in'),
|
||||
('OUT', 'out'),
|
||||
('TRANSFER', 'transfer'),
|
||||
('EXPECTED', 'kutilmoqda'),
|
||||
('ACCEPTED', 'qabul qilingan'),
|
||||
('CANCELLED', 'bekor qilingan'),
|
||||
)
|
||||
|
||||
number = models.IntegerField(default=1)
|
||||
wherehouse_to = models.ForeignKey(
|
||||
WhereHouse, on_delete=models.CASCADE, related_name='stocks_to'
|
||||
)
|
||||
wherehouse_from = models.ForeignKey(
|
||||
WhereHouse, on_delete=models.CASCADE, related_name='stocks_from'
|
||||
)
|
||||
product = models.ForeignKey(
|
||||
Product, on_delete=models.CASCADE, related_name='stocks'
|
||||
recipient = models.ForeignKey(
|
||||
User, on_delete=models.SET_NULL, related_name='stock_movmends', null=True, blank=True
|
||||
)
|
||||
quantity = models.PositiveIntegerField(default=0)
|
||||
movemend_type = models.CharField(max_length=20, choices=TYPE)
|
||||
project_folder = models.ForeignKey(
|
||||
ProjectFolder, on_delete=models.CASCADE, related_name='stock_movmends', null=True
|
||||
)
|
||||
project = models.ForeignKey(
|
||||
Project, on_delete=models.SET_NULL, related_name='stock_movmends', null=True
|
||||
)
|
||||
movemend_type = models.CharField(max_length=20, choices=TYPE, default='EXPECTED')
|
||||
date = models.DateField(null=True, blank=True)
|
||||
comment = models.TextField(null=True, blank=True)
|
||||
file = models.FileField(null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.product} send from {self.wherehouse_from} to {self.wherehouse_to}'
|
||||
return f'{self.wherehouse_from} to {self.wherehouse_to}'
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Mahsulotlarni kochirish')
|
||||
verbose_name_plural = _('Mahsulotlarni kochirish')
|
||||
|
||||
|
||||
class StockMovmendProduct(BaseModel):
|
||||
inventory = models.ForeignKey(
|
||||
Inventory, on_delete=models.CASCADE, related_name='movmend_products',
|
||||
null=True
|
||||
)
|
||||
quantity = models.PositiveIntegerField()
|
||||
stock_movemend = models.ForeignKey(
|
||||
StockMovemend, on_delete=models.CASCADE, related_name='movmend_products'
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.inventory)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Ko'chirilgan mahsulot"
|
||||
verbose_name_plural = "Ko'chirilgan mahsulotlar"
|
||||
|
||||
Reference in New Issue
Block a user