mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added part list which require more stock to be built
This commit is contained in:
parent
945c3c214d
commit
c55fa13cdb
@ -498,6 +498,22 @@ class PartList(generics.ListCreateAPIView):
|
||||
# Filter items which have an 'in_stock' level higher than 'minimum_stock'
|
||||
queryset = queryset.filter(Q(in_stock__gte=F('minimum_stock')))
|
||||
|
||||
# Filter by "parts which need stock to complete build"
|
||||
stock_to_build = params.get('stock_to_build', None)
|
||||
|
||||
if stock_to_build is not None:
|
||||
# Filter only active parts
|
||||
queryset = queryset.filter(active=True)
|
||||
parts_need_stock = []
|
||||
|
||||
# Find parts with active builds
|
||||
# where any subpart's stock is lower than quantity being built
|
||||
for part in queryset:
|
||||
if part.active_builds and part.can_build < part.quantity_being_built:
|
||||
parts_need_stock.append(part.pk)
|
||||
|
||||
queryset = queryset.filter(pk__in=parts_need_stock)
|
||||
|
||||
return queryset
|
||||
|
||||
permission_classes = [
|
||||
|
@ -32,6 +32,7 @@ InvenTree | Index
|
||||
{% include "InvenTree/low_stock.html" with collapse_id="order" %}
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
{% include "InvenTree/required_stock_build.html" with collapse_id="stock_to_build" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -60,15 +61,23 @@ loadPartTable("#latest-parts-table", "{% url 'api-part-list' %}", {
|
||||
}
|
||||
});
|
||||
|
||||
loadPartTable("#starred-parts-table", "{% url 'api-part-list' %}", {
|
||||
params: {
|
||||
"starred": true,
|
||||
}
|
||||
});
|
||||
|
||||
loadPartTable("#bom-invalid-table", "{% url 'api-part-list' %}", {
|
||||
params: {
|
||||
"bom_invalid": true,
|
||||
}
|
||||
});
|
||||
|
||||
loadPartTable("#starred-parts-table", "{% url 'api-part-list' %}", {
|
||||
loadBuildTable("#build-pending-table", {
|
||||
url: "{% url 'api-build-list' %}",
|
||||
params: {
|
||||
"starred": true,
|
||||
"part_detail": true,
|
||||
"status": "10-20",
|
||||
}
|
||||
});
|
||||
|
||||
@ -78,11 +87,9 @@ loadPartTable("#low-stock-table", "{% url 'api-part-list' %}", {
|
||||
}
|
||||
});
|
||||
|
||||
loadBuildTable("#build-pending-table", {
|
||||
url: "{% url 'api-build-list' %}",
|
||||
loadPartTable("#stock-to-build-table", "{% url 'api-part-list' %}", {
|
||||
params: {
|
||||
"part_detail": true,
|
||||
"status": "10-20",
|
||||
"stock_to_build": true,
|
||||
}
|
||||
});
|
||||
|
||||
@ -102,13 +109,6 @@ loadSalesOrderTable("#so-outstanding-table", {
|
||||
}
|
||||
});
|
||||
|
||||
$("#bom-invalid-table").on('load-success.bs.table', function() {
|
||||
var count = $("#bom-invalid-table").bootstrapTable('getData').length;
|
||||
|
||||
$("#bom-invalid-count").html(count);
|
||||
});
|
||||
|
||||
|
||||
$("#latest-parts-table").on('load-success.bs.table', function() {
|
||||
var count = $("#latest-parts-table").bootstrapTable('getData').length;
|
||||
|
||||
@ -121,10 +121,10 @@ $("#starred-parts-table").on('load-success.bs.table', function() {
|
||||
$("#starred-parts-count").html(count);
|
||||
});
|
||||
|
||||
$("#low-stock-table").on('load-success.bs.table', function() {
|
||||
var count = $("#low-stock-table").bootstrapTable('getData').length;
|
||||
$("#bom-invalid-table").on('load-success.bs.table', function() {
|
||||
var count = $("#bom-invalid-table").bootstrapTable('getData').length;
|
||||
|
||||
$("#low-stock-count").html(count);
|
||||
$("#bom-invalid-count").html(count);
|
||||
});
|
||||
|
||||
$("#build-pending-table").on('load-success.bs.table', function() {
|
||||
@ -133,6 +133,18 @@ $("#build-pending-table").on('load-success.bs.table', function() {
|
||||
$("#build-pending-count").html(count);
|
||||
});
|
||||
|
||||
$("#low-stock-table").on('load-success.bs.table', function() {
|
||||
var count = $("#low-stock-table").bootstrapTable('getData').length;
|
||||
|
||||
$("#low-stock-count").html(count);
|
||||
});
|
||||
|
||||
$("#stock-to-build-table").on('load-success.bs.table', function() {
|
||||
var count = $("#stock-to-build-table").bootstrapTable('getData').length;
|
||||
|
||||
$("#stock-to-build-count").html(count);
|
||||
});
|
||||
|
||||
$("#po-outstanding-table").on('load-success.bs.table', function() {
|
||||
var count = $("#po-outstanding-table").bootstrapTable('getData').length;
|
||||
|
||||
|
15
InvenTree/templates/InvenTree/po_outstanding.html
Normal file
15
InvenTree/templates/InvenTree/po_outstanding.html
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends "collapse_index.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block collapse_title %}
|
||||
<span class='fas fa-sign-in-alt icon-header'></span>
|
||||
{% trans "Outstanding Purchase Orders" %}<span class='badge' id='po-outstanding-count'>0</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_content %}
|
||||
|
||||
<table class='table table-striped table-condensed' id='po-outstanding-table'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
15
InvenTree/templates/InvenTree/required_stock_build.html
Normal file
15
InvenTree/templates/InvenTree/required_stock_build.html
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends "collapse_index.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block collapse_title %}
|
||||
<span class='fas fa-bullhorn icon-header'></span>
|
||||
{% trans "Require Stock To Complete Build" %}<span class='badge' id='stock-to-build-count'>0</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_content %}
|
||||
|
||||
<table class='table table-striped table-condensed' id='stock-to-build-table'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
15
InvenTree/templates/InvenTree/so_outstanding.html
Normal file
15
InvenTree/templates/InvenTree/so_outstanding.html
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends "collapse_index.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block collapse_title %}
|
||||
<span class='fas fa-sign-out-alt icon-header'></span>
|
||||
{% trans "Outstanding Sales Orders" %}<span class='badge' id='so-outstanding-count'>0</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_content %}
|
||||
|
||||
<table class='table table-striped table-condensed' id='so-outstanding-table'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user