mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Switched to ModelChoiceField
This commit is contained in:
parent
6f89f7dc7f
commit
946d824995
@ -196,11 +196,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):
|
class EditBomItemForm(HelperForm):
|
||||||
""" Form for editing a BomItem object """
|
""" Form for editing a BomItem object """
|
||||||
|
|
||||||
quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5)
|
quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5)
|
||||||
|
|
||||||
|
sub_part = PartModelChoiceField(queryset=Part.objects.all())
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BomItem
|
model = BomItem
|
||||||
fields = [
|
fields = [
|
||||||
|
@ -268,7 +268,7 @@ class Part(MPTTModel):
|
|||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.full_name} - {self.description} - {self.available_stock}"
|
return f"{self.full_name} - {self.description}"
|
||||||
|
|
||||||
def checkAddToBOM(self, parent):
|
def checkAddToBOM(self, parent):
|
||||||
"""
|
"""
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
<option value=''>--- {% trans "Select Part" %} ---</option>
|
<option value=''>--- {% trans "Select Part" %} ---</option>
|
||||||
{% for part in row.part_options %}
|
{% for part in row.part_options %}
|
||||||
<option value='{{ part.id }}' {% if part.id == row.part.id %} selected='selected' {% elif part.id == row.part_match.id %} selected='selected' {% endif %}>
|
<option value='{{ part.id }}' {% if part.id == row.part.id %} selected='selected' {% elif part.id == row.part_match.id %} selected='selected' {% endif %}>
|
||||||
{{ part }}
|
{{ part }} - {{ part.available_stock }}
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
Reference in New Issue
Block a user