Remove defunct 'build_order' field from StockItem model

- This is now handled by the new-and-improved build system, no longer required
This commit is contained in:
Oliver Walters 2020-11-10 20:12:39 +11:00
parent 978fd7c683
commit e4f2eecb3b
10 changed files with 58 additions and 34 deletions

View File

@ -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'),
),
]

View File

@ -962,7 +962,6 @@ class BuildItem(models.Model):
related_name='allocations', related_name='allocations',
help_text=_('Source stock item'), help_text=_('Source stock item'),
limit_choices_to={ limit_choices_to={
'build_order': None,
'sales_order': None, 'sales_order': None,
'belongs_to': None, 'belongs_to': None,
} }

View File

@ -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'),
),
]

View File

@ -621,7 +621,6 @@ class SalesOrderAllocation(models.Model):
'part__salable': True, 'part__salable': True,
'belongs_to': None, 'belongs_to': None,
'sales_order': None, 'sales_order': None,
'build_order': None,
}, },
help_text=_('Select stock item to allocate') help_text=_('Select stock item to allocate')
) )

View File

@ -83,8 +83,6 @@ class StockItemResource(ModelResource):
sales_order = Field(attribute='sales_order', widget=widgets.ForeignKeyWidget(SalesOrder)) 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)) purchase_order = Field(attribute='purchase_order', widget=widgets.ForeignKeyWidget(PurchaseOrder))
# Date management # Date management

View File

@ -488,11 +488,7 @@ class StockList(generics.ListCreateAPIView):
if build: if build:
queryset = queryset.filter(build=build) queryset = queryset.filter(build=build)
build_order = params.get('build_order', None) # Filter by 'is building' status
if build_order:
queryset = queryset.filter(build_order=build_order)
is_building = params.get('is_building', None) is_building = params.get('is_building', None)
if is_building: if is_building:

View File

@ -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',
),
]

View File

@ -136,7 +136,6 @@ class StockItem(MPTTModel):
purchase_order: Link to a PurchaseOrder (if this stock item was created from a PurchaseOrder) purchase_order: Link to a PurchaseOrder (if this stock item was created from a PurchaseOrder)
infinite: If True this StockItem can never be exhausted 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) 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) 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( IN_STOCK_FILTER = Q(
quantity__gt=0, quantity__gt=0,
sales_order=None, sales_order=None,
build_order=None,
belongs_to=None, belongs_to=None,
customer=None, customer=None,
is_building=False, is_building=False,
@ -430,14 +428,6 @@ class StockItem(MPTTModel):
related_name='stock_items', related_name='stock_items',
null=True, blank=True) 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 # last time the stock was checked / counted
stocktake_date = models.DateField(blank=True, null=True) stocktake_date = models.DateField(blank=True, null=True)
@ -614,9 +604,6 @@ class StockItem(MPTTModel):
if self.sales_order is not None: if self.sales_order is not None:
return False return False
if self.build_order is not None:
return False
return True return True
def installedItemCount(self): def installedItemCount(self):
@ -750,10 +737,6 @@ class StockItem(MPTTModel):
if self.sales_order is not None: if self.sales_order is not None:
return False 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 # Not 'in stock' if it has been assigned to a customer
if self.customer is not None: if self.customer is not None:
return False return False

View File

@ -73,7 +73,6 @@ class StockItemSerializer(InvenTreeModelSerializer):
return queryset.prefetch_related( return queryset.prefetch_related(
'belongs_to', 'belongs_to',
'build', 'build',
'build_order',
'customer', 'customer',
'sales_order', 'sales_order',
'supplier_part', 'supplier_part',
@ -155,7 +154,6 @@ class StockItemSerializer(InvenTreeModelSerializer):
'batch', 'batch',
'belongs_to', 'belongs_to',
'build', 'build',
'build_order',
'customer', 'customer',
'in_stock', 'in_stock',
'is_building', 'is_building',

View File

@ -221,12 +221,6 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
<td>{% trans "Sales Order" %}</td> <td>{% trans "Sales Order" %}</td>
<td><a href="{% url 'so-detail' item.sales_order.id %}">{{ item.sales_order.reference }}</a> - <a href="{% url 'company-detail' item.sales_order.customer.id %}">{{ item.sales_order.customer.name }}</a></td> <td><a href="{% url 'so-detail' item.sales_order.id %}">{{ item.sales_order.reference }}</a> - <a href="{% url 'company-detail' item.sales_order.customer.id %}">{{ item.sales_order.customer.name }}</a></td>
</tr> </tr>
{% elif item.build_order %}
<tr>
<td><span class='fas fa-tools'></span></td>
<td>{% trans "Build Order" %}</td>
<td><a href="{% url 'build-detail' item.build_order.id %}">{{ item.build_order }}</a></td>
</tr>
{% else %} {% else %}
<tr> <tr>
<td><span class='fas fa-map-marker-alt'></span></td> <td><span class='fas fa-map-marker-alt'></span></td>