From 3ef0386593e49250f99cc3f0b4fe0ceff5a9b1a5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 26 Apr 2022 17:14:47 +1000 Subject: [PATCH] Prevent inactive or trackable parts from being 'auto allocated' --- InvenTree/part/models.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index d6ca9f650c..1edae69351 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -2732,7 +2732,21 @@ class BomItem(models.Model, DataImportMixin): for sub in self.substitutes.all(): parts.add(sub.part) - return parts + valid_parts = [] + + for p in parts: + + # Inactive parts cannot be 'auto allocated' + if not p.active: + continue + + # Trackable parts cannot be 'auto allocated' + if p.trackable: + continue + + valid_parts.append(p) + + return valid_parts def is_stock_item_valid(self, stock_item): """