Added stocktake / add / remove actions to StockItemDetail page

This commit is contained in:
Oliver 2018-05-08 22:07:24 +10:00
parent 25e0de1ce7
commit 3b6ef3f008
3 changed files with 48 additions and 11 deletions

View File

@ -48,7 +48,10 @@
</div> </div>
{% endblock %} {% endblock %}
{% block js_load %}
{{ block.super }}
<script type='text/javacript' src="{% static script/inventree/stock.js' %}"></script>
{% endblock %}
{% block js_ready %} {% block js_ready %}
{{ block.super }} {{ block.super }}
@ -165,6 +168,14 @@
title: 'Stock', title: 'Stock',
searchable: false, searchable: false,
sortable: true, sortable: true,
formatter: function(value, row, index, field) {
if (value) {
return renderLink(value, row.url + 'stock/');
}
else {
return '';
}
}
} }
], ],
url: "{% url 'api-part-list' %}", url: "{% url 'api-part-list' %}",

View File

@ -14,12 +14,14 @@
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Options <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Options
<span class="caret"></span></button> <span class="caret"></span></button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#" id='stock-edit' title='Edit stock item'>Edit</a></li>
{% if item.in_stock %} {% if item.in_stock %}
<li><a href="#" id='stock-move' title='Move stock item'>Move</a></li> <li><a href='#' id='stock-stocktake' title='Count stock'>Stocktake</a></li>
<li><a href='#' id='stock-stocktake' title='Stocktake'>Stocktake</a></li> <li><a href='#' id='stock-add' title='Add stock'>Add to stock</a></li>
<li><a href='#' id='stock-remove' title='Remove stock'>Remove from stock</a></li>
<li><a href="#" id='stock-edit' title='Edit stock item'>Edit stock item</a></li>
<li><a href="#" id='stock-move' title='Move stock item'>Move stock item</a></li>
{% endif %} {% endif %}
<li><a href="#" id='stock-delete' title='Delete stock item'>Delete</a></li> <li><a href="#" id='stock-delete' title='Delete stock item'>Delete stock item</a></li>
</ul> </ul>
</div> </div>
</div> </div>
@ -128,7 +130,6 @@
</div> </div>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block js_ready %} {% block js_ready %}
{{ block.super }} {{ block.super }}
$("#stock-edit").click(function () { $("#stock-edit").click(function () {
@ -148,12 +149,31 @@
}); });
}); });
function itemAdjust(action) {
adjustStock({
query: {
pk: {{ item.id }},
},
action: action,
success: function() {
location.reload();
}
});
}
$("#stock-stocktake").click(function() { $("#stock-stocktake").click(function() {
launchModalForm( itemAdjust('stocktake');
"{% url 'stock-item-stocktake' item.id %}", return false;
{ });
reload: true
}); $('#stock-remove').click(function() {
itemAdjust('remove');
return false;
});
$('#stock-add').click(function() {
itemAdjust('add');
return false;
}); });
{% endif %} {% endif %}

View File

@ -13,6 +13,12 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block js_load %}
{{ block.super }}
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
<script type='text/javascript' src="{% static 'script/inventree/stock.js' %}"></script>
{% endblock %}
{% block js_ready %} {% block js_ready %}
initSideNav(); initSideNav();
{{ block.super }} {{ block.super }}