diff --git a/InvenTree/barcodes/api.py b/InvenTree/barcodes/api.py index 355fcab0e1..0d3656ce4c 100644 --- a/InvenTree/barcodes/api.py +++ b/InvenTree/barcodes/api.py @@ -109,14 +109,14 @@ class BarcodeScan(APIView): # No plugin is found! # However, the hash of the barcode may still be associated with a StockItem! else: - hash = hash_barcode(barcode_data) + result_hash = hash_barcode(barcode_data) - response['hash'] = hash + response['hash'] = result_hash response['plugin'] = None # Try to look for a matching StockItem try: - item = StockItem.objects.get(uid=hash) + item = StockItem.objects.get(uid=result_hash) serializer = StockItemSerializer(item, part_detail=True, location_detail=True, supplier_part_detail=True) response['stockitem'] = serializer.data response['url'] = reverse('stock-item-detail', kwargs={'pk': item.id}) @@ -182,8 +182,8 @@ class BarcodeAssign(APIView): # Matching plugin was found if plugin is not None: - hash = plugin.hash() - response['hash'] = hash + result_hash = plugin.hash() + response['hash'] = result_hash response['plugin'] = plugin.name # Ensure that the barcode does not already match a database entry @@ -208,14 +208,14 @@ class BarcodeAssign(APIView): match_found = True else: - hash = hash_barcode(barcode_data) + result_hash = hash_barcode(barcode_data) - response['hash'] = hash + response['hash'] = result_hash response['plugin'] = None # Lookup stock item by hash try: - item = StockItem.objects.get(uid=hash) + item = StockItem.objects.get(uid=result_hash) response['error'] = _('Barcode hash already matches Stock Item') match_found = True except StockItem.DoesNotExist: diff --git a/InvenTree/barcodes/tests.py b/InvenTree/barcodes/tests.py index 1d8f53ec4c..a9795c3928 100644 --- a/InvenTree/barcodes/tests.py +++ b/InvenTree/barcodes/tests.py @@ -124,12 +124,12 @@ class BarcodeAPITest(APITestCase): self.assertIn('success', data) - hash = data['hash'] + result_hash = data['hash'] # Read the item out from the database again item = StockItem.objects.get(pk=522) - self.assertEqual(hash, item.uid) + self.assertEqual(result_hash, item.uid) # Ensure that the same UID cannot be assigned to a different stock item! response = self.client.post( diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 0625a717a5..d146c3d7b3 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -446,10 +446,10 @@ class PartSerialNumberDetail(generics.RetrieveAPIView): } if latest is not None: - next = increment(latest) + next_serial = increment(latest) - if next != increment: - data['next'] = next + if next_serial != increment: + data['next'] = next_serial return Response(data) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 1566c1a9f0..d186a9b5e7 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1530,15 +1530,15 @@ class Part(MPTTModel): returns a string representation of a hash object which can be compared with a stored value """ - hash = hashlib.md5(str(self.id).encode()) + result_hash = hashlib.md5(str(self.id).encode()) # List *all* BOM items (including inherited ones!) bom_items = self.get_bom_items().all().prefetch_related('sub_part') for item in bom_items: - hash.update(str(item.get_item_hash()).encode()) + result_hash.update(str(item.get_item_hash()).encode()) - return str(hash.digest()) + return str(result_hash.digest()) def is_bom_valid(self): """ Check if the BOM is 'valid' - if the calculated checksum matches the stored value @@ -2676,18 +2676,18 @@ class BomItem(models.Model): """ # Seed the hash with the ID of this BOM item - hash = hashlib.md5(str(self.id).encode()) + result_hash = hashlib.md5(str(self.id).encode()) # Update the hash based on line information - hash.update(str(self.sub_part.id).encode()) - hash.update(str(self.sub_part.full_name).encode()) - hash.update(str(self.quantity).encode()) - hash.update(str(self.note).encode()) - hash.update(str(self.reference).encode()) - hash.update(str(self.optional).encode()) - hash.update(str(self.inherited).encode()) + result_hash.update(str(self.sub_part.id).encode()) + result_hash.update(str(self.sub_part.full_name).encode()) + result_hash.update(str(self.quantity).encode()) + result_hash.update(str(self.note).encode()) + result_hash.update(str(self.reference).encode()) + result_hash.update(str(self.optional).encode()) + result_hash.update(str(self.inherited).encode()) - return str(hash.digest()) + return str(result_hash.digest()) def validate_hash(self, valid=True): """ Mark this item as 'valid' (store the checksum hash). diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 64b8b8536f..627b925e23 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -293,7 +293,7 @@ def progress_bar(val, max, *args, **kwargs): Render a progress bar element """ - id = kwargs.get('id', 'progress-bar') + item_id = kwargs.get('id', 'progress-bar') if val > max: style = 'progress-bar-over' @@ -317,7 +317,7 @@ def progress_bar(val, max, *args, **kwargs): style_tags.append(f'max-width: {max_width};') html = f""" -