mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Re-enable auto-allocation for build
This commit is contained in:
parent
3685ca4b95
commit
646dd65d27
@ -450,7 +450,7 @@ class BuildItem(models.Model):
|
|||||||
q=self.stock_item.quantity
|
q=self.stock_item.quantity
|
||||||
))]
|
))]
|
||||||
|
|
||||||
if self.stock_item.quantity - self.stock_item.allocation_count() < self.quantity:
|
if self.stock_item.quantity - self.stock_item.allocation_count() + self.quantity < self.quantity:
|
||||||
errors['quantity'] = _('StockItem is over-allocated')
|
errors['quantity'] = _('StockItem is over-allocated')
|
||||||
|
|
||||||
if self.quantity <= 0:
|
if self.quantity <= 0:
|
||||||
|
@ -12,11 +12,13 @@ InvenTree | Allocate Parts
|
|||||||
{% include "build/tabs.html" with tab='allocate' %}
|
{% include "build/tabs.html" with tab='allocate' %}
|
||||||
|
|
||||||
<div id='build-item-toolbar'>
|
<div id='build-item-toolbar'>
|
||||||
|
{% if build.status == BuildStatus.PENDING %}
|
||||||
<div class='btn-group'>
|
<div class='btn-group'>
|
||||||
<button class='btn btn-primary' type='button' id='btn-order-parts' title='Order Parts'>{% trans "Order Parts" %}</button>
|
<button class='btn btn-primary' type='button' id='btn-order-parts' title='Order Parts'>{% trans "Order Parts" %}</button>
|
||||||
{% if 0 %}<button class='btn btn-primary' type='button' id='btn-allocate' title='Allocate Stock'>{% trans "Allocate" %}</button>{% endif %}
|
<button class='btn btn-primary' type='button' id='btn-allocate' title='{% trans "Automatically allocate stock" %}'>{% trans "Auto Allocate" %}</button>
|
||||||
<button class='btn btn-danger' type='button' id='btn-unallocate' title='Unallocate Stock'>{% trans "Unallocate" %}</button>
|
<button class='btn btn-danger' type='button' id='btn-unallocate' title='Unallocate Stock'>{% trans "Unallocate" %}</button>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class='table table-striped table-condensed' id='build-item-list' data-toolbar='#build-item-toolbar'></table>
|
<table class='table table-striped table-condensed' id='build-item-list' data-toolbar='#build-item-toolbar'></table>
|
||||||
@ -151,7 +153,15 @@ InvenTree | Allocate Parts
|
|||||||
field: 'quantity',
|
field: 'quantity',
|
||||||
title: 'Quantity',
|
title: 'Quantity',
|
||||||
formatter: function(value, row, index, field) {
|
formatter: function(value, row, index, field) {
|
||||||
return renderLink(value, `/stock/item/${row.stock_item}/`);
|
var text = '';
|
||||||
|
|
||||||
|
if (row.serial && row.quantity == 1) {
|
||||||
|
text = `{% trans "Serial Number" %}: ${row.serial}`;
|
||||||
|
} else {
|
||||||
|
text = `{% trans "Quantity" %}: ${row.quantity}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return renderLink(text, `/stock/item/${row.stock_item}/`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -330,8 +340,8 @@ InvenTree | Allocate Parts
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
{% if 0 %}
|
{% if build.status == BuildStatus.PENDING %}
|
||||||
$("#auto-allocate-build").on('click', function() {
|
$("#btn-allocate").on('click', function() {
|
||||||
launchModalForm(
|
launchModalForm(
|
||||||
"{% url 'build-auto-allocate' build.id %}",
|
"{% url 'build-auto-allocate' build.id %}",
|
||||||
{
|
{
|
||||||
@ -339,8 +349,7 @@ InvenTree | Allocate Parts
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
$('#btn-unallocate').on('click', function() {
|
$('#btn-unallocate').on('click', function() {
|
||||||
launchModalForm(
|
launchModalForm(
|
||||||
"{% url 'build-unallocate' build.id %}",
|
"{% url 'build-unallocate' build.id %}",
|
||||||
@ -349,7 +358,7 @@ InvenTree | Allocate Parts
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#btn-order-parts").click(function() {
|
$("#btn-order-parts").click(function() {
|
||||||
launchModalForm("/order/purchase-order/order-parts/", {
|
launchModalForm("/order/purchase-order/order-parts/", {
|
||||||
data: {
|
data: {
|
||||||
@ -357,5 +366,8 @@ InvenTree | Allocate Parts
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
@ -1,22 +1,23 @@
|
|||||||
{% extends "modal_form.html" %}
|
{% extends "modal_form.html" %}
|
||||||
|
{% load i18n %}
|
||||||
{% block pre_form_content %}
|
{% block pre_form_content %}
|
||||||
|
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
<b>Build: {{ build.title }}</b> - {{ build.quantity }} x {{ build.part.full_name }}
|
<div class='alert alert-block alert-info'>
|
||||||
<br><br>
|
<b>{% trans "Automatically Allocate Stock" %}</b><br>
|
||||||
Automatically allocate stock to this build?
|
{% trans "Stock Items are selected for automatic allocation if there is only a single stock item available." %}<br>
|
||||||
<hr>
|
{% trans "The following stock items will be allocated to the build:" %}<br>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% if allocations %}
|
{% if allocations %}
|
||||||
|
|
||||||
<table class='table table-striped table-condensed'>
|
<table class='table table-striped table-condensed'>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Part</th>
|
<th>{% trans "Part" %}</th>
|
||||||
<th>Quantity</th>
|
<th>{% trans "Quantity" %}</th>
|
||||||
<th>Location</th>
|
<th>{% trans "Location" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for item in allocations %}
|
{% for item in allocations %}
|
||||||
<tr>
|
<tr>
|
||||||
@ -34,7 +35,9 @@ Automatically allocate stock to this build?
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<i>No stock could be selected for automatic build allocation.</i>
|
<div class='alert alert-block alert-warning'>
|
||||||
|
{% trans "No stock items found that can be allocated to this build" %}
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -49,7 +49,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if part.trackable %}
|
{% if part.trackable %}
|
||||||
<li{% ifequal tab 'track' %} class="active"{% endifequal %}>
|
<li{% if 0 and ifequal tab 'track' %} class="active"{% endifequal %}>
|
||||||
<a href="{% url 'part-track' part.id %}">{% trans "Tracking" %}
|
<a href="{% url 'part-track' part.id %}">{% trans "Tracking" %}
|
||||||
{% if parts.serials.all|length > 0 %}
|
{% if parts.serials.all|length > 0 %}
|
||||||
<span class="badge">{{ part.serials.all|length }}</span>
|
<span class="badge">{{ part.serials.all|length }}</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user