mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Limit choices for 'parent' field when editing StockLocation
This commit is contained in:
parent
fb38ddb1b3
commit
afffd06fb8
@ -75,6 +75,24 @@ class StockLocationEdit(AjaxUpdateView):
|
|||||||
ajax_template_name = 'modal_form.html'
|
ajax_template_name = 'modal_form.html'
|
||||||
ajax_form_title = 'Edit Stock Location'
|
ajax_form_title = 'Edit Stock Location'
|
||||||
|
|
||||||
|
def get_form(self):
|
||||||
|
""" Customize form data for StockLocation editing.
|
||||||
|
|
||||||
|
Limit the choices for 'parent' field to those which make sense.
|
||||||
|
"""
|
||||||
|
|
||||||
|
form = super(AjaxUpdateView, self).get_form()
|
||||||
|
|
||||||
|
location = self.get_object()
|
||||||
|
|
||||||
|
# Remove any invalid choices for the 'parent' field
|
||||||
|
parent_choices = StockLocation.objects.all()
|
||||||
|
parent_choices = parent_choices.exclude(id__in=location.getUniqueChildren())
|
||||||
|
|
||||||
|
form.fields['parent'].queryset = parent_choices
|
||||||
|
|
||||||
|
return form
|
||||||
|
|
||||||
|
|
||||||
class StockLocationQRCode(QRCodeView):
|
class StockLocationQRCode(QRCodeView):
|
||||||
""" View for displaying a QR code for a StockLocation object """
|
""" View for displaying a QR code for a StockLocation object """
|
||||||
|
Loading…
Reference in New Issue
Block a user