2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 05:25:42 +00:00

Merge branch 'inventree:master' into style-fix

This commit is contained in:
Matthias Mair
2022-01-24 23:39:17 +01:00
committed by GitHub
20 changed files with 58 additions and 65 deletions

View File

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

View File

@ -75,7 +75,6 @@ class BomMatchItemForm(MatchItemForm):
})
)
# return default
return super().get_special_field(col_guess, row, file_manager)

View File

@ -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
@ -2188,9 +2188,7 @@ def after_save_part(sender, instance: Part, created, **kwargs):
Function to be executed after a Part is saved
"""
if created:
pass
else:
if not created:
# Check part stock only if we are *updating* the part (not creating it)
# Run this check in the background
@ -2678,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).

View File

@ -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"""
<div id='{id}' class='progress' style='{" ".join(style_tags)}'>
<div id='{item_id}' class='progress' style='{" ".join(style_tags)}'>
<div class='progress-bar {style}' role='progressbar' aria-valuemin='0' aria-valuemax='100' style='width:{percent}%'></div>
<div class='progress-value'>{val} / {max}</div>
</div>

View File

@ -30,8 +30,8 @@ class TemplateTagTest(TestCase):
self.assertEqual(type(inventree_extras.inventree_version()), str)
def test_hash(self):
hash = inventree_extras.inventree_commit_hash()
self.assertGreater(len(hash), 5)
result_hash = inventree_extras.inventree_commit_hash()
self.assertGreater(len(result_hash), 5)
def test_date(self):
d = inventree_extras.inventree_commit_date()

View File

@ -1,7 +0,0 @@
from django.test import TestCase
class SupplierPartTest(TestCase):
def setUp(self):
pass