mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Cleanup queryset for BomItemEdit view
This commit is contained in:
		| @@ -2497,6 +2497,8 @@ class BomItemEdit(AjaxUpdateView): | |||||||
|         - Remove any part items that are already in the BOM |         - Remove any part items that are already in the BOM | ||||||
|         """ |         """ | ||||||
|  |  | ||||||
|  |         item = self.get_object() | ||||||
|  |  | ||||||
|         form = super().get_form() |         form = super().get_form() | ||||||
|  |  | ||||||
|         part_id = form['part'].value() |         part_id = form['part'].value() | ||||||
| @@ -2504,9 +2506,14 @@ class BomItemEdit(AjaxUpdateView): | |||||||
|         try: |         try: | ||||||
|             part = Part.objects.get(pk=part_id) |             part = Part.objects.get(pk=part_id) | ||||||
|  |  | ||||||
|             query = form.fields['sub_part'].queryset |             # Construct a queryset | ||||||
|  |             query = Part.objects.filter(component=True) | ||||||
|  |  | ||||||
|             # Reduce the available selection options |             # Limit to "active" items, *unless* the currently selected item is not active | ||||||
|  |             if item.sub_part.active: | ||||||
|  |                 query = query.filter(active=True) | ||||||
|  |  | ||||||
|  |             # Prevent the parent part from being selected | ||||||
|             query = query.exclude(pk=part_id) |             query = query.exclude(pk=part_id) | ||||||
|  |  | ||||||
|             # Eliminate any options that are already in the BOM, |             # Eliminate any options that are already in the BOM, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user