mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-10 05:40:55 +00:00
Add API endpoint for validating a BOM item
This commit is contained in:
@@ -1176,16 +1176,28 @@ class BomItem(models.Model):
|
||||
|
||||
return str(hash.digest())
|
||||
|
||||
def validate_hash(self):
|
||||
""" Mark this item as 'valid' (store the checksum hash) """
|
||||
def validate_hash(self, valid=True):
|
||||
""" Mark this item as 'valid' (store the checksum hash).
|
||||
|
||||
Args:
|
||||
valid: If true, validate the hash, otherwise invalidate it (default = True)
|
||||
"""
|
||||
|
||||
if valid:
|
||||
self.checksum = str(self.get_item_hash())
|
||||
else:
|
||||
self.checksum = ''
|
||||
|
||||
self.checksum = str(self.get_item_hash())
|
||||
self.save()
|
||||
|
||||
@property
|
||||
def is_line_valid(self):
|
||||
""" Check if this line item has been validated by the user """
|
||||
|
||||
# Ensure an empty checksum returns False
|
||||
if len(self.checksum) == 0:
|
||||
return False
|
||||
|
||||
return self.get_item_hash() == self.checksum
|
||||
|
||||
def clean(self):
|
||||
|
Reference in New Issue
Block a user