diff --git a/InvenTree/build/migrations/0023_auto_20201110_0911.py b/InvenTree/build/migrations/0023_auto_20201110_0911.py new file mode 100644 index 0000000000..3d95e6844e --- /dev/null +++ b/InvenTree/build/migrations/0023_auto_20201110_0911.py @@ -0,0 +1,20 @@ +# Generated by Django 3.0.7 on 2020-11-10 09:11 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0054_remove_stockitem_build_order'), + ('build', '0022_buildorderattachment'), + ] + + operations = [ + migrations.AlterField( + model_name='builditem', + name='stock_item', + field=models.ForeignKey(help_text='Source stock item', limit_choices_to={'belongs_to': None, 'sales_order': None}, on_delete=django.db.models.deletion.CASCADE, related_name='allocations', to='stock.StockItem'), + ), + ] diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index a18328be1a..a18471ccc6 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -962,7 +962,6 @@ class BuildItem(models.Model): related_name='allocations', help_text=_('Source stock item'), limit_choices_to={ - 'build_order': None, 'sales_order': None, 'belongs_to': None, } diff --git a/InvenTree/order/migrations/0037_auto_20201110_0911.py b/InvenTree/order/migrations/0037_auto_20201110_0911.py new file mode 100644 index 0000000000..9594424e5d --- /dev/null +++ b/InvenTree/order/migrations/0037_auto_20201110_0911.py @@ -0,0 +1,20 @@ +# Generated by Django 3.0.7 on 2020-11-10 09:11 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0054_remove_stockitem_build_order'), + ('order', '0036_auto_20200831_0912'), + ] + + operations = [ + migrations.AlterField( + model_name='salesorderallocation', + name='item', + field=models.ForeignKey(help_text='Select stock item to allocate', limit_choices_to={'belongs_to': None, 'part__salable': True, 'sales_order': None}, on_delete=django.db.models.deletion.CASCADE, related_name='sales_order_allocations', to='stock.StockItem'), + ), + ] diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index b193454e1f..359b0cf752 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -621,7 +621,6 @@ class SalesOrderAllocation(models.Model): 'part__salable': True, 'belongs_to': None, 'sales_order': None, - 'build_order': None, }, help_text=_('Select stock item to allocate') ) diff --git a/InvenTree/stock/admin.py b/InvenTree/stock/admin.py index 5917ed8e22..5f3c08839d 100644 --- a/InvenTree/stock/admin.py +++ b/InvenTree/stock/admin.py @@ -83,8 +83,6 @@ class StockItemResource(ModelResource): sales_order = Field(attribute='sales_order', widget=widgets.ForeignKeyWidget(SalesOrder)) - build_order = Field(attribute='build_order', widget=widgets.ForeignKeyWidget(Build)) - purchase_order = Field(attribute='purchase_order', widget=widgets.ForeignKeyWidget(PurchaseOrder)) # Date management diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 5d71d00a0c..dc16fb52a6 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -488,11 +488,7 @@ class StockList(generics.ListCreateAPIView): if build: queryset = queryset.filter(build=build) - build_order = params.get('build_order', None) - - if build_order: - queryset = queryset.filter(build_order=build_order) - + # Filter by 'is building' status is_building = params.get('is_building', None) if is_building: diff --git a/InvenTree/stock/migrations/0054_remove_stockitem_build_order.py b/InvenTree/stock/migrations/0054_remove_stockitem_build_order.py new file mode 100644 index 0000000000..b0da00ab52 --- /dev/null +++ b/InvenTree/stock/migrations/0054_remove_stockitem_build_order.py @@ -0,0 +1,17 @@ +# Generated by Django 3.0.7 on 2020-11-10 09:11 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0053_auto_20201110_0513'), + ] + + operations = [ + migrations.RemoveField( + model_name='stockitem', + name='build_order', + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 4f4057eb88..9e31774946 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -136,7 +136,6 @@ class StockItem(MPTTModel): purchase_order: Link to a PurchaseOrder (if this stock item was created from a PurchaseOrder) infinite: If True this StockItem can never be exhausted sales_order: Link to a SalesOrder object (if the StockItem has been assigned to a SalesOrder) - build_order: Link to a BuildOrder object (if the StockItem has been assigned to a BuildOrder) purchase_price: The unit purchase price for this StockItem - this is the unit price at time of purchase (if this item was purchased from an external supplier) """ @@ -144,7 +143,6 @@ class StockItem(MPTTModel): IN_STOCK_FILTER = Q( quantity__gt=0, sales_order=None, - build_order=None, belongs_to=None, customer=None, is_building=False, @@ -430,14 +428,6 @@ class StockItem(MPTTModel): related_name='stock_items', null=True, blank=True) - build_order = models.ForeignKey( - 'build.Build', - on_delete=models.SET_NULL, - verbose_name=_("Destination Build Order"), - related_name='stock_items', - null=True, blank=True - ) - # last time the stock was checked / counted stocktake_date = models.DateField(blank=True, null=True) @@ -614,9 +604,6 @@ class StockItem(MPTTModel): if self.sales_order is not None: return False - if self.build_order is not None: - return False - return True def installedItemCount(self): @@ -750,10 +737,6 @@ class StockItem(MPTTModel): if self.sales_order is not None: return False - # Not 'in stock' if it has been allocated to a BuildOrder - if self.build_order is not None: - return False - # Not 'in stock' if it has been assigned to a customer if self.customer is not None: return False diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 5bea1c4aae..e8675a8fff 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -73,7 +73,6 @@ class StockItemSerializer(InvenTreeModelSerializer): return queryset.prefetch_related( 'belongs_to', 'build', - 'build_order', 'customer', 'sales_order', 'supplier_part', @@ -155,7 +154,6 @@ class StockItemSerializer(InvenTreeModelSerializer): 'batch', 'belongs_to', 'build', - 'build_order', 'customer', 'in_stock', 'is_building', diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 38ed9723a6..5e9d26c5cf 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -221,12 +221,6 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% trans "Sales Order" %} {{ item.sales_order.reference }} - {{ item.sales_order.customer.name }} - {% elif item.build_order %} - - - {% trans "Build Order" %} - {{ item.build_order }} - {% else %}