diff --git a/InvenTree/build/migrations/0013_build_take_from.py b/InvenTree/build/migrations/0013_build_take_from.py new file mode 100644 index 0000000000..9945da2be1 --- /dev/null +++ b/InvenTree/build/migrations/0013_build_take_from.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2 on 2019-05-10 08:50 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0015_stockitem_delete_on_deplete'), + ('build', '0012_auto_20190508_2332'), + ] + + operations = [ + migrations.AddField( + model_name='build', + name='take_from', + field=models.ForeignKey(blank=True, help_text='Select location to take stock from for this build (leave blank to take from any stock location', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sourcing_builds', to='stock.StockLocation'), + ), + ] diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 0b658dee1a..4a9084825f 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -27,6 +27,7 @@ class Build(models.Model): part: The part to be built (from component BOM items) title: Brief title describing the build (required) quantity: Number of units to be built + take_from: Location to take stock from to make this build (if blank, can take from anywhere) status: Build status code batch: Batch code transferred to build parts (optional) creation_date: Date the build was created (auto) @@ -41,6 +42,11 @@ class Build(models.Model): def get_absolute_url(self): return reverse('build-detail', kwargs={'pk': self.id}) + title = models.CharField( + blank=False, + max_length=100, + help_text='Brief description of the build') + part = models.ForeignKey('part.Part', on_delete=models.CASCADE, related_name='builds', limit_choices_to={ @@ -50,10 +56,11 @@ class Build(models.Model): help_text='Select part to build', ) - title = models.CharField( - blank=False, - max_length=100, - help_text='Brief description of the build') + take_from = models.ForeignKey('stock.StockLocation', on_delete=models.SET_NULL, + related_name='sourcing_builds', + null=True, blank=True, + help_text='Select location to take stock from for this build (leave blank to take from any stock location' + ) quantity = models.PositiveIntegerField( default=1,