from django.db import models

from products.models import Product
from utils.models import Utility


class Inventory(Utility):
    inventory_number = models.CharField(unique=True, max_length=100, blank=True, null=True)
    supplier = models.CharField(max_length=100, blank=True, null=True)
    user = models.ForeignKey('auth.User', on_delete=models.SET_NULL, blank=True, null=True)
    is_adjusment = models.BooleanField(default=False)

    def __str__(self):
        return self.inventory_number


class InventoryItem(Utility):
    inventory = models.ForeignKey(Inventory, on_delete=models.CASCADE)
    product = models.ForeignKey(Product, on_delete=models.CASCADE)
    quantity = models.PositiveIntegerField(default=1)

    def __str__(self):
        return self.product.name





[((8, 23, 8, 91), 'django.db.models.CharField', 'models.CharField', (), '', False, 'from django.db import models\n'), ((9, 15, 9, 70), 'django.db.models.CharField', 'models.CharField', (), '', False, 'from django.db import models\n'), ((10, 11, 10, 91), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((11, 19, 11, 53), 'django.db.models.BooleanField', 'models.BooleanField', (), '', False, 'from django.db import models\n'), ((18, 16, 18, 70), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((19, 14, 19, 66), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((20, 15, 20, 53), 'django.db.models.PositiveIntegerField', 'models.PositiveIntegerField', (), '', False, 'from django.db import models\n')]