{% extends "stock/stock_app_base.html" %}
{% load static %}
{% load inventree_extras %}
{% load i18n %}
{% block sidebar %}
{% include "stock/location_sidebar.html" %}
{% endblock %}
{% block breadcrumb_tree %}
{% endblock breadcrumb_tree %}
{% block heading %}
{% if location %}
{% trans "Stock Location" %}: {{ location.name }}
{% else %}
{% trans "Stock" %}
{% endif %}
{% endblock %}
{% block actions %}
{% if location and user.is_staff and roles.stock_location.change %}
{% url 'admin:stock_stocklocation_change' location.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
{% if barcodes %}
{% if location %}
{% if user_owns_location %}
{% if roles.stock.change %}
{% endif %}
{% if roles.stock_location.change %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if user_owns_location and roles.stock_location.add %}
{% endif %}
{% endblock %}
{% block details_left %}
{% if location %}
{% if location.description %}
|
{% trans "Description" %} |
{{ location.description }} |
{% endif %}
|
{% trans "Location Path" %} |
{{ location.pathstring }} |
{% else %}
|
{% trans "Location Path" %} |
{% trans "Top level stock location" %} |
{% endif %}
{% if ownership_enabled and location_owner %}
|
{% trans "Location Owner" %} |
{{ location_owner }}
{% if not user_owns_location %}
{% trans "Read only" %}
{% endif %}
|
{% endif %}
{% endblock details_left %}
{% block details_right %}
{% if location %}
|
{% trans "Sublocations" %} |
{{ location.children.count }} |
|
{% trans "Stock Items" %} |
{{ location.item_count }} |
{% else %}
|
{% trans "Stock Locations" %} |
{{ loc_count }} |
|
{% trans "Stock Items" %} |
{{ stock_count }} |
{% endif %}
{% endblock details_right %}
{% block page_content %}
{% trans "Stock Items" %}
{% include "spacer.html" %}
{% include "stock_table.html" %}
{% trans "Sublocations" %}
{% endblock %}
{% block js_ready %}
{{ block.super }}
loadStockLocationTable($('#sublocation-table'), {
params: {
{% if location %}
parent: {{ location.pk }},
{% else %}
parent: 'null',
{% endif %}
},
allowTreeView: true,
});
linkButtonsToSelection(
$('#sublocation-table'),
[
'#location-print-options',
]
);
$('#multi-location-print-label').click(function() {
var selections = $('#sublocation-table').bootstrapTable('getSelections');
var locations = [];
selections.forEach(function(loc) {
locations.push(loc.pk);
});
printStockLocationLabels(locations);
});
{% if location %}
$("#barcode-check-in").click(function() {
barcodeCheckIn({{ location.id }});
});
{% endif %}
$("#stock-export").click(function() {
downloadTableData($('#stock-table'));
});
$('#location-create').click(function () {
createStockLocation({
{% if location %}
parent: {{ location.pk }},
{% endif %}
follow: true,
});
});
{% if location %}
$('#location-edit').click(function() {
editStockLocation({{ location.id }}, {
reload: true,
});
});
$('#location-delete').click(function() {
launchModalForm("{% url 'stock-location-delete' location.id %}",
{
redirect: "{% url 'stock-index' %}"
});
return false;
});
{% if location %}
function adjustLocationStock(action) {
inventreeGet(
'{% url "api-stock-list" %}',
{
location: {{ location.id }},
in_stock: true,
part_detail: true,
location_detail: true,
},
{
success: function(items) {
adjustStock(action, items, {
success: function() {
location.reload();
}
});
}
}
);
}
$("#location-count").click(function() {
adjustLocationStock('count');
});
$("#location-move").click(function() {
adjustLocationStock('move');
});
$('#print-label').click(function() {
var locs = [{{ location.pk }}];
printStockLocationLabels(locs);
});
{% endif %}
$('#show-qr-code').click(function() {
launchModalForm("{% url 'stock-location-qr' location.id %}",
{
no_post: true,
});
});
{% endif %}
$('#item-create').click(function () {
createNewStockItem({
data: {
{% if location %}
location: {{ location.id }}
{% endif %}
},
});
});
loadStockTable($("#stock-table"), {
buttons: [
'#stock-options',
],
params: {
{% if location %}
location: {{ location.pk }},
{% endif %}
part_detail: true,
location_detail: true,
supplier_part_detail: true,
},
url: "{% url 'api-stock-list' %}",
});
enableSidebar('stocklocation');
// Enable breadcrumb tree view
enableBreadcrumbTree({
label: 'location',
url: '{% url "api-location-tree" %}',
{% if location %}
selected: {{ location.pk }},
{% endif %}
processNode: function(node) {
node.text = node.name;
node.href = `/stock/location/${node.pk}/`;
return node;
}
});
{% endblock %}