Add option to move stock for a part

This commit is contained in:
Oliver 2021-07-12 20:45:45 +10:00
parent 9fc7976569
commit 2ea4824030
2 changed files with 39 additions and 9 deletions

View File

@ -49,9 +49,25 @@
<span id='part-price-icon' class='fas fa-dollar-sign'/> <span id='part-price-icon' class='fas fa-dollar-sign'/>
</button> </button>
{% if roles.stock.change %} {% if roles.stock.change %}
<button type='button' class='btn btn-default' id='part-count' title='{% trans "Count part stock" %}'> <div class='btn-group'>
<span class='fas fa-clipboard-list'/> <button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>
</button> <span class='fas fa-boxes'></span> <span class='caret'></span>
</button>
<ul class='dropdown-menu'>
<li>
<a href='#' id='part-count'>
<span class='fas fa-clipboard-list'></span>
{% trans "Count part stock" %}
</a>
</li>
<li>
<a href='#' id='part-move'>
<span class='fas fa-exchange-alt'></span>
{% trans "Move part stock" %}
</a>
</li>
</ul>
</div>
{% endif %} {% endif %}
{% if part.purchaseable %} {% if part.purchaseable %}
{% if roles.purchase_order.add %} {% if roles.purchase_order.add %}
@ -272,7 +288,7 @@
printPartLabels([{{ part.pk }}]); printPartLabels([{{ part.pk }}]);
}); });
$("#part-count").click(function() { function adjustPartStock(action) {
inventreeGet( inventreeGet(
'{% url "api-stock-list" %}', '{% url "api-stock-list" %}',
{ {
@ -284,7 +300,7 @@
}, },
{ {
success: function(items) { success: function(items) {
adjustStock('count', items, { adjustStock(action, items, {
onSuccess: function() { onSuccess: function() {
location.reload(); location.reload();
} }
@ -292,6 +308,14 @@
}, },
} }
); );
}
$("#part-move").click(function() {
adjustPartStock('move');
});
$("#part-count").click(function() {
adjustPartStock('count');
}); });
$("#price-button").click(function() { $("#price-button").click(function() {

View File

@ -59,11 +59,17 @@
{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %} {% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %}
{% if roles.stock.change %} {% if roles.stock.change %}
<div class='btn-group'> <div class='btn-group'>
<button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button> <button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>
<span class='fas fa-boxes'></span> <span class='caret'></span>
</button>
<ul class='dropdown-menu' role='menu'> <ul class='dropdown-menu' role='menu'>
<li><a href='#' id='location-count'><span class='fas fa-clipboard-list'></span> <li>
{% trans "Count stock" %}</a></li> <a href='#' id='location-count'>
</ul> <span class='fas fa-clipboard-list'></span>
{% trans "Count stock" %}
</a>
</li>
</ul>
</div> </div>
{% endif %} {% endif %}
{% if roles.stock_location.change %} {% if roles.stock_location.change %}