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
|
||||
))]
|
||||
|
||||
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')
|
||||
|
||||
if self.quantity <= 0:
|
||||
|
@ -12,11 +12,13 @@ InvenTree | Allocate Parts
|
||||
{% include "build/tabs.html" with tab='allocate' %}
|
||||
|
||||
<div id='build-item-toolbar'>
|
||||
{% if build.status == BuildStatus.PENDING %}
|
||||
<div class='btn-group'>
|
||||
<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>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<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',
|
||||
title: 'Quantity',
|
||||
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 %}
|
||||
$("#auto-allocate-build").on('click', function() {
|
||||
{% if build.status == BuildStatus.PENDING %}
|
||||
$("#btn-allocate").on('click', function() {
|
||||
launchModalForm(
|
||||
"{% url 'build-auto-allocate' build.id %}",
|
||||
{
|
||||
@ -339,8 +349,7 @@ InvenTree | Allocate Parts
|
||||
}
|
||||
);
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
|
||||
$('#btn-unallocate').on('click', function() {
|
||||
launchModalForm(
|
||||
"{% url 'build-unallocate' build.id %}",
|
||||
@ -349,7 +358,7 @@ InvenTree | Allocate Parts
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
$("#btn-order-parts").click(function() {
|
||||
launchModalForm("/order/purchase-order/order-parts/", {
|
||||
data: {
|
||||
@ -357,5 +366,8 @@ InvenTree | Allocate Parts
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
@ -1,22 +1,23 @@
|
||||
{% extends "modal_form.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% block pre_form_content %}
|
||||
|
||||
{{ block.super }}
|
||||
|
||||
<b>Build: {{ build.title }}</b> - {{ build.quantity }} x {{ build.part.full_name }}
|
||||
<br><br>
|
||||
Automatically allocate stock to this build?
|
||||
<hr>
|
||||
<div class='alert alert-block alert-info'>
|
||||
<b>{% trans "Automatically Allocate Stock" %}</b><br>
|
||||
{% trans "Stock Items are selected for automatic allocation if there is only a single stock item available." %}<br>
|
||||
{% trans "The following stock items will be allocated to the build:" %}<br>
|
||||
</div>
|
||||
|
||||
{% if allocations %}
|
||||
|
||||
<table class='table table-striped table-condensed'>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Part</th>
|
||||
<th>Quantity</th>
|
||||
<th>Location</th>
|
||||
<th>{% trans "Part" %}</th>
|
||||
<th>{% trans "Quantity" %}</th>
|
||||
<th>{% trans "Location" %}</th>
|
||||
</tr>
|
||||
{% for item in allocations %}
|
||||
<tr>
|
||||
@ -34,7 +35,9 @@ Automatically allocate stock to this build?
|
||||
</table>
|
||||
|
||||
{% 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 %}
|
||||
|
||||
{% endblock %}
|
@ -49,7 +49,7 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% 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" %}
|
||||
{% if parts.serials.all|length > 0 %}
|
||||
<span class="badge">{{ part.serials.all|length }}</span>
|
||||
|
Loading…
Reference in New Issue
Block a user