From 6603d6e9edb136866cf70626ea1938e095d3ee08 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 26 May 2019 00:22:05 +1000 Subject: [PATCH] PEP fixes --- InvenTree/stock/api.py | 1 - InvenTree/stock/models.py | 11 +++++------ InvenTree/stock/views.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index aec679a46f..ec998dde41 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -285,7 +285,6 @@ class StockList(generics.ListCreateAPIView): # Does the client wish to filter by stock location? loc_id = self.request.query_params.get('location', None) - if loc_id: try: location = StockLocation.objects.get(pk=loc_id) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 5d297df946..f6651f6dd4 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -122,7 +122,6 @@ class StockItem(models.Model): # ensure that the serial number is unique # across all variants of the same template part - try: if self.serial is not None and self.part.variant_of is not None: if StockItem.objects.filter(part__variant_of=self.part.variant_of, serial=self.serial).exclude(id=self.id).exists(): @@ -211,11 +210,11 @@ class StockItem(models.Model): ) part = models.ForeignKey('part.Part', on_delete=models.CASCADE, - related_name='stock_items', help_text='Base part', - limit_choices_to={ - 'is_template': False, - 'active': True, - }) + related_name='stock_items', help_text='Base part', + limit_choices_to={ + 'is_template': False, + 'active': True, + }) supplier_part = models.ForeignKey('company.SupplierPart', blank=True, null=True, on_delete=models.SET_NULL, help_text='Select a matching supplier part for this stock item') diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index d729cb83fc..42ca16d3ba 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -208,9 +208,9 @@ class StockItemCreate(AjaxCreateView): try: part = Part.objects.get(id=part_id) + # Hide the 'part' field (as a valid part is selected) form.fields['part'].widget = HiddenInput() - # If the part is NOT purchaseable, hide the supplier_part field if not part.purchaseable: