mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-14 19:15:41 +00:00
Added help text for model fields
This commit is contained in:
19
InvenTree/stock/migrations/0014_auto_20190508_2332.py
Normal file
19
InvenTree/stock/migrations/0014_auto_20190508_2332.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 2.2 on 2019-05-08 13:32
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0013_remove_stockitem_uuid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='stockitem',
|
||||
name='supplier_part',
|
||||
field=models.ForeignKey(blank=True, help_text='Select a matching supplier part for this stock item', null=True, on_delete=django.db.models.deletion.SET_NULL, to='part.SupplierPart'),
|
||||
),
|
||||
]
|
@ -163,7 +163,8 @@ class StockItem(models.Model):
|
||||
part = models.ForeignKey('part.Part', on_delete=models.CASCADE, related_name='locations', help_text='Base part')
|
||||
|
||||
# The 'supplier part' used in this instance. May be null if no supplier parts are defined the master part
|
||||
supplier_part = models.ForeignKey('part.SupplierPart', blank=True, null=True, on_delete=models.SET_NULL)
|
||||
supplier_part = models.ForeignKey('part.SupplierPart', blank=True, null=True, on_delete=models.SET_NULL,
|
||||
help_text='Select a matching supplier part for this stock item')
|
||||
|
||||
# Where the part is stored. If the part has been used to build another stock item, the location may not make sense
|
||||
location = models.ForeignKey(StockLocation, on_delete=models.DO_NOTHING,
|
||||
|
@ -207,6 +207,14 @@ class StockItemCreate(AjaxCreateView):
|
||||
parts = form.fields['supplier_part'].queryset
|
||||
parts = parts.filter(part=part.id)
|
||||
form.fields['supplier_part'].queryset = parts
|
||||
|
||||
# If there is one (and only one) supplier part available, pre-select it
|
||||
all_parts = parts.all()
|
||||
if len(all_parts) == 1:
|
||||
|
||||
# TODO - This does NOT work for some reason? Ref build.views.BuildItemCreate
|
||||
form.fields['supplier_part'].initial = all_parts[0].id
|
||||
|
||||
except Part.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user