2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-15 01:11:27 +00:00

fix reused builtins

This commit is contained in:
Matthias
2022-01-21 00:17:52 +01:00
parent cbd84a23f9
commit c44565f9e3
7 changed files with 31 additions and 31 deletions

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