mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 04:56:45 +00:00
PEP fixes
This commit is contained in:
parent
f4ef9d938e
commit
09cb067627
@ -5,54 +5,57 @@ from django.db import models
|
|||||||
from InvenTree.models import Company
|
from InvenTree.models import Company
|
||||||
from part.models import Part
|
from part.models import Part
|
||||||
|
|
||||||
|
|
||||||
class Supplier(Company):
|
class Supplier(Company):
|
||||||
""" Represents a manufacturer or supplier
|
""" Represents a manufacturer or supplier
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Customer(Company):
|
class Customer(Company):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SupplierPart(models.Model):
|
class SupplierPart(models.Model):
|
||||||
""" Represents a unique part as provided by a Supplier
|
""" Represents a unique part as provided by a Supplier
|
||||||
Each SupplierPart is identified by a MPN (Manufacturer Part Number)
|
Each SupplierPart is identified by a MPN (Manufacturer Part Number)
|
||||||
Each SupplierPart is also linked to a Part object
|
Each SupplierPart is also linked to a Part object
|
||||||
- A Part may be available from multiple suppliers
|
- A Part may be available from multiple suppliers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
supplier = models.ForeignKey(Supplier,
|
supplier = models.ForeignKey(Supplier,
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
part = models.ForeignKey(Part,
|
part = models.ForeignKey(Part,
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
|
|
||||||
MPN = models.CharField(max_length=100)
|
MPN = models.CharField(max_length=100)
|
||||||
URL = models.URLField(blank=True)
|
URL = models.URLField(blank=True)
|
||||||
description = models.CharField(max_length=250,
|
description = models.CharField(max_length=250,
|
||||||
blank=True)
|
blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{mpn} - {supplier}".format(
|
return "{mpn} - {supplier}".format(
|
||||||
mpn = self.MPN,
|
mpn = self.MPN,
|
||||||
supplier = self.supplier.name)
|
supplier = self.supplier.name)
|
||||||
|
|
||||||
|
|
||||||
class SupplierPriceBreak(models.Model):
|
class SupplierPriceBreak(models.Model):
|
||||||
""" Represents a quantity price break for a SupplierPart
|
""" Represents a quantity price break for a SupplierPart
|
||||||
- Suppliers can offer discounts at larger quantities
|
- Suppliers can offer discounts at larger quantities
|
||||||
- SupplierPart(s) may have zero-or-more associated SupplierPriceBreak(s)
|
- SupplierPart(s) may have zero-or-more associated SupplierPriceBreak(s)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
part = models.ForeignKey(SupplierPart,
|
part = models.ForeignKey(SupplierPart,
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
quantity = models.IntegerField()
|
quantity = models.IntegerField()
|
||||||
cost = models.DecimalField(max_digits=10, decimal_places=3)
|
cost = models.DecimalField(max_digits=10, decimal_places=3)
|
||||||
currency = models.CharField(max_length=10,
|
currency = models.CharField(max_length=10,
|
||||||
blank=True)
|
blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{mpn} - {cost}{currency} @ {quan}".format(
|
return "{mpn} - {cost}{currency} @ {quan}".format(
|
||||||
mpn = part.MPN,
|
mpn=part.MPN,
|
||||||
cost = self.cost,
|
cost=self.cost,
|
||||||
currency = self.currency if self.currency else '',
|
currency=self.currency if self.currency else '',
|
||||||
quan = self.quantity)
|
quan=self.quantity)
|
@ -6,27 +6,28 @@ from django.contrib.auth.models import User
|
|||||||
from supplier.models import Customer
|
from supplier.models import Customer
|
||||||
from part.models import Part, PartRevision
|
from part.models import Part, PartRevision
|
||||||
|
|
||||||
|
|
||||||
class UniquePart(models.Model):
|
class UniquePart(models.Model):
|
||||||
""" A unique instance of a Part object.
|
""" A unique instance of a Part object.
|
||||||
Used for tracking parts based on serial numbers,
|
Used for tracking parts based on serial numbers,
|
||||||
and tracking all events in the life of a part
|
and tracking all events in the life of a part
|
||||||
"""
|
"""
|
||||||
|
|
||||||
part = models.ForeignKey(Part, on_delete=models.CASCADE)
|
part = models.ForeignKey(Part, on_delete=models.CASCADE)
|
||||||
|
|
||||||
revision = models.ForeignKey(PartRevision,
|
revision = models.ForeignKey(PartRevision,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True)
|
null=True)
|
||||||
|
|
||||||
creation_date = models.DateField(auto_now_add=True,
|
creation_date = models.DateField(auto_now_add=True,
|
||||||
editable=False)
|
editable=False)
|
||||||
serial = models.IntegerField()
|
serial = models.IntegerField()
|
||||||
|
|
||||||
createdBy = models.ForeignKey(User)
|
createdBy = models.ForeignKey(User)
|
||||||
|
|
||||||
customer = models.ForeignKey(Customer, blank=True, null=True)
|
customer = models.ForeignKey(Customer, blank=True, null=True)
|
||||||
|
|
||||||
# Part status types
|
# Part status types
|
||||||
PART_IN_PROGRESS = 0
|
PART_IN_PROGRESS = 0
|
||||||
PART_IN_STOCK = 10
|
PART_IN_STOCK = 10
|
||||||
@ -34,29 +35,28 @@ class UniquePart(models.Model):
|
|||||||
PART_RETURNED = 30
|
PART_RETURNED = 30
|
||||||
PART_DAMAGED = 40
|
PART_DAMAGED = 40
|
||||||
PART_DESTROYED = 50
|
PART_DESTROYED = 50
|
||||||
|
|
||||||
status = models.IntegerField(default=PART_IN_PROGRESS,
|
status = models.IntegerField(default=PART_IN_PROGRESS,
|
||||||
choices=[
|
choices=[
|
||||||
(PART_IN_PROGRESS, "In progress"),
|
(PART_IN_PROGRESS, "In progress"),
|
||||||
(PART_IN_STOCK, "In stock"),
|
(PART_IN_STOCK, "In stock"),
|
||||||
(PART_SHIPPED, "Shipped"),
|
(PART_SHIPPED, "Shipped"),
|
||||||
(PART_RETURNED, "Returned"),
|
(PART_RETURNED, "Returned"),
|
||||||
(PART_DAMAGED, "Damaged"),
|
(PART_DAMAGED, "Damaged"),
|
||||||
(PART_DESTROYED, "Destroyed"),
|
(PART_DESTROYED, "Destroyed"),
|
||||||
])
|
])
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.part.name
|
return self.part.name
|
||||||
|
|
||||||
|
|
||||||
class PartTrackingInfo(models.Model):
|
class PartTrackingInfo(models.Model):
|
||||||
""" Single data-point in the life of a UniquePart
|
""" Single data-point in the life of a UniquePart
|
||||||
Each time something happens to the UniquePart,
|
Each time something happens to the UniquePart,
|
||||||
a new PartTrackingInfo object should be created.
|
a new PartTrackingInfo object should be created.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
part = models.ForeignKey(UniquePart, on_delete=models.CASCADE)
|
part = models.ForeignKey(UniquePart, on_delete=models.CASCADE)
|
||||||
date = models.DateField(auto_now_add=True,
|
date = models.DateField(auto_now_add=True,
|
||||||
editable=False)
|
editable=False)
|
||||||
notes = models.CharField(max_length=500)
|
notes = models.CharField(max_length=500)
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user