Add "install_into" field for BuildItem

- Points to which output stock item it will be going into
This commit is contained in:
Oliver Walters 2020-10-20 20:37:57 +11:00
parent 85ac1bfb95
commit fdcef7b699
3 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,25 @@
# Generated by Django 3.0.7 on 2020-10-20 09:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('stock', '0052_stockitem_is_building'),
('build', '0020_auto_20201019_1325'),
]
operations = [
migrations.AddField(
model_name='builditem',
name='install_into',
field=models.ForeignKey(blank=True, help_text='Destination stock item', limit_choices_to={'is_building': True}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='items_to_install', to='stock.StockItem'),
),
migrations.AlterField(
model_name='builditem',
name='stock_item',
field=models.ForeignKey(help_text='Source stock item', limit_choices_to={'belongs_to': None, 'build_order': None, 'sales_order': None}, on_delete=django.db.models.deletion.CASCADE, related_name='allocations', to='stock.StockItem'),
),
]

View File

@ -568,7 +568,7 @@ class BuildItem(models.Model):
'stock.StockItem',
on_delete=models.CASCADE,
related_name='allocations',
help_text=_('Stock Item to allocate to build'),
help_text=_('Source stock item'),
limit_choices_to={
'build_order': None,
'sales_order': None,
@ -583,3 +583,14 @@ class BuildItem(models.Model):
validators=[MinValueValidator(0)],
help_text=_('Stock quantity to allocate to build')
)
install_into = models.ForeignKey(
'stock.StockItem',
on_delete=models.SET_NULL,
blank=True, null=True,
related_name='items_to_install',
help_text=_('Destination stock item'),
limit_choices_to={
'is_building': True,
}
)

View File

@ -493,6 +493,12 @@ class StockList(generics.ListCreateAPIView):
if build_order:
queryset = queryset.filter(build_order=build_order)
is_building = params.get('is_building', None)
if is_building:
is_building = str2bool(is_building)
queryset = queryset.filter(is_building=is_building)
sales_order = params.get('sales_order', None)
if sales_order: