From 489dfa1823b07a653e09ab0a76ff3942378679c0 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 27 Apr 2020 20:45:01 +1000 Subject: [PATCH] Bug fix for a code path which resulted in a form failing validation but not showing any errors! This one has been here for a while! --- InvenTree/stock/views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index f32f3a9a95..b6ec8bda85 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -838,9 +838,12 @@ class StockItemCreate(AjaxCreateView): if part_id: try: part = Part.objects.get(pk=part_id) - initials['part'] = part - initials['location'] = part.get_default_location() - initials['supplier_part'] = part.default_supplier + # Check that the supplied part is 'valid' + if not part.is_template and part.active and not part.virtual: + initials['part'] = part + initials['location'] = part.get_default_location() + initials['supplier_part'] = part.default_supplier + except (ValueError, Part.DoesNotExist): pass