diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py
index 8dccf7f28b..a578e19011 100644
--- a/InvenTree/part/forms.py
+++ b/InvenTree/part/forms.py
@@ -200,11 +200,19 @@ class EditCategoryForm(HelperForm):
]
+class PartModelChoiceField(forms.ModelChoiceField):
+ """ Extending string representation of Part instance with available stock """
+ def label_from_instance(self, part):
+ return f'{part} - {part.available_stock}'
+
+
class EditBomItemForm(HelperForm):
""" Form for editing a BomItem object """
quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5)
+ sub_part = PartModelChoiceField(queryset=Part.objects.all())
+
class Meta:
model = BomItem
fields = [
diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py
index 239d8fabdb..e5b035f856 100644
--- a/InvenTree/part/models.py
+++ b/InvenTree/part/models.py
@@ -268,7 +268,7 @@ class Part(MPTTModel):
super().save(*args, **kwargs)
def __str__(self):
- return "{n} - {d}".format(n=self.full_name, d=self.description)
+ return f"{self.full_name} - {self.description}"
def checkAddToBOM(self, parent):
"""
diff --git a/InvenTree/part/templates/part/bom_upload/select_parts.html b/InvenTree/part/templates/part/bom_upload/select_parts.html
index d84cb0262f..ede92c6c30 100644
--- a/InvenTree/part/templates/part/bom_upload/select_parts.html
+++ b/InvenTree/part/templates/part/bom_upload/select_parts.html
@@ -63,7 +63,7 @@
{% for part in row.part_options %}
{% endfor %}