From 09cb0676272a344e9430cedd411dc405391c5980 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 28 Mar 2017 23:09:51 +1100 Subject: [PATCH] PEP fixes --- InvenTree/supplier/models.py | 29 ++++++++++++++----------- InvenTree/track/models.py | 42 ++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/InvenTree/supplier/models.py b/InvenTree/supplier/models.py index 6af88f57a8..e3d4a7546e 100644 --- a/InvenTree/supplier/models.py +++ b/InvenTree/supplier/models.py @@ -5,54 +5,57 @@ from django.db import models from InvenTree.models import Company from part.models import Part + class Supplier(Company): """ Represents a manufacturer or supplier """ pass - + + class Customer(Company): pass - + + class SupplierPart(models.Model): """ Represents a unique part as provided by a Supplier Each SupplierPart is identified by a MPN (Manufacturer Part Number) Each SupplierPart is also linked to a Part object - A Part may be available from multiple suppliers """ - + supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE) part = models.ForeignKey(Part, on_delete=models.CASCADE) - + MPN = models.CharField(max_length=100) URL = models.URLField(blank=True) description = models.CharField(max_length=250, blank=True) - + def __str__(self): return "{mpn} - {supplier}".format( mpn = self.MPN, supplier = self.supplier.name) - - + + class SupplierPriceBreak(models.Model): """ Represents a quantity price break for a SupplierPart - Suppliers can offer discounts at larger quantities - SupplierPart(s) may have zero-or-more associated SupplierPriceBreak(s) """ - + part = models.ForeignKey(SupplierPart, on_delete=models.CASCADE) quantity = models.IntegerField() cost = models.DecimalField(max_digits=10, decimal_places=3) currency = models.CharField(max_length=10, blank=True) - + def __str__(self): return "{mpn} - {cost}{currency} @ {quan}".format( - mpn = part.MPN, - cost = self.cost, - currency = self.currency if self.currency else '', - quan = self.quantity) \ No newline at end of file + mpn=part.MPN, + cost=self.cost, + currency=self.currency if self.currency else '', + quan=self.quantity) \ No newline at end of file diff --git a/InvenTree/track/models.py b/InvenTree/track/models.py index 1060d3bf40..9f6ffb3525 100644 --- a/InvenTree/track/models.py +++ b/InvenTree/track/models.py @@ -6,27 +6,28 @@ from django.contrib.auth.models import User from supplier.models import Customer from part.models import Part, PartRevision + class UniquePart(models.Model): """ A unique instance of a Part object. Used for tracking parts based on serial numbers, and tracking all events in the life of a part """ - + part = models.ForeignKey(Part, on_delete=models.CASCADE) - + revision = models.ForeignKey(PartRevision, on_delete=models.CASCADE, blank=True, null=True) - + creation_date = models.DateField(auto_now_add=True, - editable=False) + editable=False) serial = models.IntegerField() - + createdBy = models.ForeignKey(User) - + customer = models.ForeignKey(Customer, blank=True, null=True) - + # Part status types PART_IN_PROGRESS = 0 PART_IN_STOCK = 10 @@ -34,29 +35,28 @@ class UniquePart(models.Model): PART_RETURNED = 30 PART_DAMAGED = 40 PART_DESTROYED = 50 - + status = models.IntegerField(default=PART_IN_PROGRESS, - choices=[ - (PART_IN_PROGRESS, "In progress"), - (PART_IN_STOCK, "In stock"), - (PART_SHIPPED, "Shipped"), - (PART_RETURNED, "Returned"), - (PART_DAMAGED, "Damaged"), - (PART_DESTROYED, "Destroyed"), - ]) + choices=[ + (PART_IN_PROGRESS, "In progress"), + (PART_IN_STOCK, "In stock"), + (PART_SHIPPED, "Shipped"), + (PART_RETURNED, "Returned"), + (PART_DAMAGED, "Damaged"), + (PART_DESTROYED, "Destroyed"), + ]) def __str__(self): return self.part.name - + + class PartTrackingInfo(models.Model): """ Single data-point in the life of a UniquePart Each time something happens to the UniquePart, a new PartTrackingInfo object should be created. """ - + part = models.ForeignKey(UniquePart, on_delete=models.CASCADE) date = models.DateField(auto_now_add=True, editable=False) - notes = models.CharField(max_length=500) - - \ No newline at end of file + notes = models.CharField(max_length=500) \ No newline at end of file