2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

More work

- Consolidated "in_stock" filter to single code location
- Improve 'limit_choices_to' for BuildItem and SalesOrderAllocation
- Various template improvements etc
This commit is contained in:
Oliver Walters
2020-04-26 16:38:29 +10:00
parent 4147163418
commit e768ada83b
20 changed files with 362 additions and 79 deletions

View File

@ -53,6 +53,8 @@ class BuildList(generics.ListCreateAPIView):
def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)
# Filter by build status?
status = self.request.query_params.get('status', None)

View File

@ -0,0 +1,20 @@
# Generated by Django 3.0.5 on 2020-04-26 05:51
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('stock', '0033_auto_20200426_0539'),
('build', '0015_auto_20200425_1350'),
]
operations = [
migrations.AlterField(
model_name='builditem',
name='stock_item',
field=models.ForeignKey(help_text='Stock Item to allocate to build', limit_choices_to={'belongs_to': None, 'build_order': None, 'customer': None}, on_delete=django.db.models.deletion.CASCADE, related_name='allocations', to='stock.StockItem'),
),
]

View File

@ -0,0 +1,20 @@
# Generated by Django 3.0.5 on 2020-04-26 06:12
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('stock', '0034_auto_20200426_0602'),
('build', '0016_auto_20200426_0551'),
]
operations = [
migrations.AlterField(
model_name='builditem',
name='stock_item',
field=models.ForeignKey(help_text='Stock Item to allocate to build', 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

@ -261,8 +261,6 @@ class Build(MPTTModel):
- Delete pending BuildItem objects
"""
print("Complete build...")
# Complete the build allocation for each BuildItem
for build_item in self.allocated_stock.all().prefetch_related('stock_item'):
build_item.complete_allocation(user)
@ -495,6 +493,11 @@ class BuildItem(models.Model):
on_delete=models.CASCADE,
related_name='allocations',
help_text=_('Stock Item to allocate to build'),
limit_choices_to={
'build_order': None,
'sales_order': None,
'belongs_to': None,
}
)
quantity = models.DecimalField(

View File

@ -82,7 +82,7 @@ src="{% static 'img/blank_image.png' %}"
</tr>
{% if build.parent %}
<tr>
<td><span class='fas fa-tools'></span></td>
<td><span class='fas fa-sitemap'></span></td>
<td>{% trans "Parent Build" %}</td>
<td><a href="{% url 'build-detail' build.parent.id %}">{{ build.parent }}</a></td>
</tr>