mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Don't restrict BomItem form to active parts for editing
This commit is contained in:
parent
b6a6e2dae7
commit
60050e9f32
@ -107,6 +107,7 @@
|
||||
<td>In Stock</td>
|
||||
<td>{{ part.total_stock }}</td>
|
||||
</tr>
|
||||
{% if not part.is_template %}
|
||||
{% if part.allocation_count > 0 %}
|
||||
<tr>
|
||||
<td>Allocated</td>
|
||||
@ -119,10 +120,12 @@
|
||||
<td>{{ part.on_order }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td><b>Total Available</b></td>
|
||||
<td><b>{{ part.net_stock }}</b></td>
|
||||
</tr>
|
||||
{% if not part.is_template %}
|
||||
{% if part.assembly %}
|
||||
<tr>
|
||||
<td colspan='2'>
|
||||
@ -139,6 +142,7 @@
|
||||
<td>{{ part.quantity_being_built }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
|
@ -1042,6 +1042,9 @@ class BomItemCreate(AjaxCreateView):
|
||||
query = query.exclude(id__in=[item.id for item in part.required_parts()])
|
||||
|
||||
form.fields['sub_part'].queryset = query
|
||||
|
||||
form.fields['part'].widget = HiddenInput()
|
||||
|
||||
except Part.DoesNotExist:
|
||||
pass
|
||||
|
||||
@ -1076,40 +1079,6 @@ class BomItemEdit(AjaxUpdateView):
|
||||
ajax_template_name = 'modal_form.html'
|
||||
ajax_form_title = 'Edit BOM item'
|
||||
|
||||
def get_form(self):
|
||||
""" Override get_form() method to reduce Part selection options.
|
||||
|
||||
- Do not allow part to be added to its own BOM
|
||||
- Remove any Part items that are already in the BOM
|
||||
"""
|
||||
|
||||
form = super(AjaxCreateView, self).get_form()
|
||||
|
||||
part_id = form['part'].value()
|
||||
|
||||
try:
|
||||
part = Part.objects.get(id=part_id)
|
||||
|
||||
# Only allow active parts to be selected
|
||||
query = form.fields['part'].queryset.filter(active=True)
|
||||
form.fields['part'].queryset = query
|
||||
|
||||
# Don't allow selection of sub_part objects which are already added to the Bom!
|
||||
query = form.fields['sub_part'].queryset
|
||||
|
||||
# Don't allow a part to be added to its own BOM
|
||||
query = query.exclude(id=part.id)
|
||||
query = query.filter(active=True)
|
||||
|
||||
# Eliminate any options that are already in the BOM!
|
||||
query = query.exclude(id__in=[item.id for item in part.required_parts()])
|
||||
|
||||
form.fields['sub_part'].queryset = query
|
||||
except Part.DoesNotExist:
|
||||
pass
|
||||
|
||||
return form
|
||||
|
||||
|
||||
class BomItemDelete(AjaxDeleteView):
|
||||
""" Delete view for removing BomItem """
|
||||
|
Loading…
Reference in New Issue
Block a user