From 11a9b49ae6af0794ed9d8b75d4febe2023095478 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 23 Jul 2026 22:49:09 +1000 Subject: [PATCH] [bug] BOM checksum fix (#12455) (#12457) * Enforce ordering of BOM items * Add prefetch to getRequiredParts --- src/backend/InvenTree/part/models.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/InvenTree/part/models.py b/src/backend/InvenTree/part/models.py index 876b5e521b..2f02dc8142 100644 --- a/src/backend/InvenTree/part/models.py +++ b/src/backend/InvenTree/part/models.py @@ -2061,7 +2061,14 @@ class Part( result_hash = hashlib.md5(str(self.id).encode()) # 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: result_hash.update(str(item.get_item_hash()).encode()) @@ -2134,7 +2141,7 @@ class Part( if parts is None: parts = set() - bom_items = self.get_bom_items() + bom_items = self.get_bom_items().prefetch_related('sub_part') for bom_item in bom_items: sub_part = bom_item.sub_part