From ff0d163a95ce4c9f7f960562a566880d1a960519 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 May 2019 18:05:29 +1000 Subject: [PATCH] Limit SupplierPart choices in EditStockItem view --- InvenTree/stock/views.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index fc174fa3f1..1f6f85ea1a 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -115,6 +115,22 @@ class StockItemEdit(AjaxUpdateView): ajax_template_name = 'modal_form.html' ajax_form_title = 'Edit Stock Item' + def get_form(self): + """ Get form for StockItem editing. + + Limit the choices for supplier_part + """ + + form = super(AjaxUpdateView, self).get_form() + + item = self.get_object() + + query = form.fields['supplier_part'].queryset + query = query.filter(part=item.part.id) + form.fields['supplier_part'].queryset = query + + return form + class StockLocationCreate(AjaxCreateView): """