PEP fixes

This commit is contained in:
Oliver Walters 2019-05-26 00:22:05 +10:00
parent 75b21bdd8f
commit 6603d6e9ed
3 changed files with 6 additions and 8 deletions

View File

@ -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)

View File

@ -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')

View File

@ -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: