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





[((150, 218), 'django.db.models.CharField', 'models.CharField', ([], {'unique': '(True)', 'max_length': '(100)', 'blank': '(True)', 'null': '(True)'}), '(unique=True, max_length=100, blank=True, null=True)\n', (166, 218), False, 'from django.db import models\n'), ((234, 289), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(100)', 'blank': '(True)', 'null': '(True)'}), '(max_length=100, blank=True, null=True)\n', (250, 289), False, 'from django.db import models\n'), ((301, 386), 'django.db.models.ForeignKey', 'models.ForeignKey', (['"""auth.User"""'], {'on_delete': 'models.SET_NULL', 'blank': '(True)', 'null': '(True)'}), "('auth.User', on_delete=models.SET_NULL, blank=True, null=True\n    )\n", (318, 386), False, 'from django.db import models\n'), ((401, 435), 'django.db.models.BooleanField', 'models.BooleanField', ([], {'default': '(False)'}), '(default=False)\n', (420, 435), False, 'from django.db import models\n'), ((545, 599), 'django.db.models.ForeignKey', 'models.ForeignKey', (['Inventory'], {'on_delete': 'models.CASCADE'}), '(Inventory, on_delete=models.CASCADE)\n', (562, 599), False, 'from django.db import models\n'), ((614, 666), 'django.db.models.ForeignKey', 'models.ForeignKey', (['Product'], {'on_delete': 'models.CASCADE'}), '(Product, on_delete=models.CASCADE)\n', (631, 666), False, 'from django.db import models\n'), ((682, 720), 'django.db.models.PositiveIntegerField', 'models.PositiveIntegerField', ([], {'default': '(1)'}), '(default=1)\n', (709, 720), False, 'from django.db import models\n')]