add new app
This commit is contained in:
3
core/apps/wherehouse/models/__init__.py
Normal file
3
core/apps/wherehouse/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .inventory import *
|
||||
from .wherehouse import *
|
||||
from .stock_movemend import *
|
||||
20
core/apps/wherehouse/models/inventory.py
Normal file
20
core/apps/wherehouse/models/inventory.py
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
|
||||
|
||||
class Inventory(BaseModel):
|
||||
wherehouse = models.ForeignKey(WhereHouse, on_delete=models.CASCADE, related_name='inventories')
|
||||
quantity = models.PositiveIntegerField(default=0)
|
||||
product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='inventories')
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.product} in {self.wherehouse}'
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('inventar')
|
||||
verbose_name_plural = _("inventarlar")
|
||||
|
||||
33
core/apps/wherehouse/models/stock_movemend.py
Normal file
33
core/apps/wherehouse/models/stock_movemend.py
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
|
||||
|
||||
class StockMovemend(BaseModel):
|
||||
TYPE = (
|
||||
('IN', 'in'),
|
||||
('OUT', 'out'),
|
||||
('TRANSFER', 'transfer'),
|
||||
)
|
||||
|
||||
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'
|
||||
)
|
||||
quantity = models.PositiveIntegerField(default=0)
|
||||
movemend_type = models.CharField(max_length=20, choices=TYPE)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.product} send from {self.wherehouse_from} to {self.wherehouse_to}'
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Mahsulotlarni kochirish')
|
||||
verbose_name_plural = _('Mahsulotlarni kochirish')
|
||||
18
core/apps/wherehouse/models/wherehouse.py
Normal file
18
core/apps/wherehouse/models/wherehouse.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.apps.shared.models import BaseModel
|
||||
from core.apps.company.models.branch import Branch
|
||||
|
||||
|
||||
class WhereHouse(BaseModel):
|
||||
branch = models.ForeignKey(Branch, on_delete=models.CASCADE, related_name='wherehouses')
|
||||
name = models.CharField(max_length=200)
|
||||
address = models.CharField(max_length=200)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('omborxona')
|
||||
verbose_name_plural = _('omborxonalar')
|
||||
Reference in New Issue
Block a user