mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add "destination" field to BuildOrder
This commit is contained in:
parent
28460b3023
commit
ac79e131bc
@ -322,7 +322,7 @@ class AjaxCreateView(AjaxMixin, CreateView):
|
||||
"""
|
||||
pass
|
||||
|
||||
def post_save(self, **kwargs):
|
||||
def post_save(self, new_object, **kwargs):
|
||||
"""
|
||||
Hook for doing something with the created object after it is saved
|
||||
"""
|
||||
@ -356,7 +356,7 @@ class AjaxCreateView(AjaxMixin, CreateView):
|
||||
|
||||
self.pre_save()
|
||||
self.object = self.form.save()
|
||||
self.post_save()
|
||||
self.post_save(self.object)
|
||||
|
||||
# Return the PK of the newly-created object
|
||||
data['pk'] = self.object.pk
|
||||
|
@ -35,10 +35,11 @@ class EditBuildForm(HelperForm):
|
||||
'title',
|
||||
'part',
|
||||
'quantity',
|
||||
'batch',
|
||||
'take_from',
|
||||
'destination',
|
||||
'parent',
|
||||
'sales_order',
|
||||
'take_from',
|
||||
'batch',
|
||||
'link',
|
||||
]
|
||||
|
||||
|
26
InvenTree/build/migrations/0022_auto_20201020_0953.py
Normal file
26
InvenTree/build/migrations/0022_auto_20201020_0953.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Generated by Django 3.0.7 on 2020-10-20 09:53
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import mptt.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0052_stockitem_is_building'),
|
||||
('build', '0021_auto_20201020_0908'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='build',
|
||||
name='destination',
|
||||
field=models.ForeignKey(blank=True, help_text='Select location where the completed items will be stored', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='incoming_builds', to='stock.StockLocation', verbose_name='Destination Location'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='build',
|
||||
name='parent',
|
||||
field=mptt.fields.TreeForeignKey(blank=True, help_text='BuildOrder to which this build is allocated', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='children', to='build.Build', verbose_name='Parent Build'),
|
||||
),
|
||||
]
|
@ -102,7 +102,7 @@ class Build(MPTTModel):
|
||||
blank=True, null=True,
|
||||
related_name='children',
|
||||
verbose_name=_('Parent Build'),
|
||||
help_text=_('Parent build to which this build is allocated'),
|
||||
help_text=_('BuildOrder to which this build is allocated'),
|
||||
)
|
||||
|
||||
part = models.ForeignKey(
|
||||
@ -137,6 +137,15 @@ class Build(MPTTModel):
|
||||
help_text=_('Select location to take stock from for this build (leave blank to take from any stock location)')
|
||||
)
|
||||
|
||||
destination = models.ForeignKey(
|
||||
'stock.StockLocation',
|
||||
verbose_name=_('Destination Location'),
|
||||
on_delete=models.SET_NULL,
|
||||
related_name='incoming_builds',
|
||||
null=True, blank=True,
|
||||
help_text=_('Select location where the completed items will be stored'),
|
||||
)
|
||||
|
||||
quantity = models.PositiveIntegerField(
|
||||
verbose_name=_('Build Quantity'),
|
||||
default=1,
|
||||
|
@ -43,7 +43,7 @@ InvenTree | {% trans "Build Orders" %}
|
||||
launchModalForm(
|
||||
"{% url 'build-create' %}",
|
||||
{
|
||||
follow: true
|
||||
follow: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -412,8 +412,17 @@ class BuildCreate(AjaxCreateView):
|
||||
|
||||
initials = super(BuildCreate, self).get_initial().copy()
|
||||
|
||||
part = self.request.GET.get('part', None)
|
||||
|
||||
if part:
|
||||
|
||||
try:
|
||||
part = Part.objects.get(pk=part)
|
||||
# User has provided a Part ID
|
||||
initials['part'] = self.request.GET.get('part', None)
|
||||
initials['part'] = part
|
||||
initials['destination'] = part.get_default_location()
|
||||
except (ValueError, Part.DoesNotExist):
|
||||
pass
|
||||
|
||||
initials['reference'] = Build.getNextBuildNumber()
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
{% if part.getLatestSerialNumber %}
|
||||
{{ part.getLatestSerialNumber }}
|
||||
{% else %}
|
||||
{% trans "No serial numbers recorded" %}
|
||||
<i>{% trans "No serial numbers recorded" %}</i>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user