[bug] BOM checksum fix (#12455) (#12457)

* Enforce ordering of BOM items

* Add prefetch to getRequiredParts
This commit is contained in:
Oliver
2026-07-23 22:49:09 +10:00
committed by GitHub
parent 3c86e8b0e9
commit 11a9b49ae6
+9 -2
View File
@@ -2061,7 +2061,14 @@ class Part(
result_hash = hashlib.md5(str(self.id).encode()) result_hash = hashlib.md5(str(self.id).encode())
# List *all* BOM items (including inherited ones!) # List *all* BOM items (including inherited ones!)
bom_items = self.get_bom_items().all().prefetch_related('part', 'sub_part') # Note: We must order the BOM items in a consistent way, otherwise the hash will change if the order of the items changes
bom_items = (
self
.get_bom_items()
.all()
.prefetch_related('part', 'sub_part')
.order_by('pk')
)
for item in bom_items: for item in bom_items:
result_hash.update(str(item.get_item_hash()).encode()) result_hash.update(str(item.get_item_hash()).encode())
@@ -2134,7 +2141,7 @@ class Part(
if parts is None: if parts is None:
parts = set() parts = set()
bom_items = self.get_bom_items() bom_items = self.get_bom_items().prefetch_related('sub_part')
for bom_item in bom_items: for bom_item in bom_items:
sub_part = bom_item.sub_part sub_part = bom_item.sub_part