{% extends "page_base.html" %}
{% load static %}
{% load inventree_extras %}
{% load status_codes %}
{% load i18n %}
{% load l10n %}
{% block page_title %}
{% inventree_title %} | {% trans "Stock Item" %} - {{ item }}
{% endblock %}
{% block breadcrumbs %}
{% include 'stock/loc_link.html' with location=item.location %}
{% endblock %}
{% block breadcrumb_tree %}
|
{% trans "Base Part" %} |
{% if roles.part.view %}
{% endif %}
{{ item.part.full_name }}
{% if roles.part.view %}
{% endif %}
|
{% if item.serialized %}
|
{% trans "Serial Number" %} |
{{ item.serial }}
|
{% else %}
|
{% trans "Quantity" %} |
{% decimal item.quantity %} {% if item.part.units %}{{ item.part.units }}{% endif %} |
{% endif %}
|
{% trans "Status" %} |
{% stock_status_label item.status %} |
{% if item.expiry_date %}
|
{% trans "Expiry Date" %} |
{{ item.expiry_date }}
{% if item.is_expired %}
{% trans "Expired" %}
{% elif item.is_stale %}
{% trans "Stale" %}
{% endif %}
|
{% endif %}
|
{% trans "Last Updated" %} |
{{ item.updated }} |
|
{% trans "Last Stocktake" %} |
{% if item.stocktake_date %}
{{ item.stocktake_date }} {{ item.stocktake_user }} |
{% else %}
{% trans "No stocktake performed" %} |
{% endif %}
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
{% if owner_control.value == "True" %}
{% authorized_owners item.owner as owners %}
{% endif %}
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
{% if owner_control.value == "True" %}
{% authorized_owners item.owner as owners %}
{% if not user in owners and not user.is_superuser %}
{% trans "You are not in the list of owners of this item. This stock item cannot be edited." %}
{% endif %}
{% endif %}
{% if item.is_building %}
{% trans "This stock item is in production and cannot be edited." %}
{% trans "Edit the stock item from the build view." %}
{% if item.build %}
{{ item.build }}
{% endif %}
{% endif %}
{% if item.hasRequiredTests and not item.passedAllRequiredTests %}
{% trans "This stock item has not passed all required tests" %}
{% endif %}
{% for allocation in item.sales_order_allocations.all %}
{% object_link 'so-detail' allocation.line.order.id allocation.line.order as link %}
{% decimal allocation.quantity as qty %}
{% trans "This stock item is allocated to Sales Order" %} {{ link }} {% if qty < item.quantity %}({% trans "Quantity" %}: {{ qty }}){% endif %}
{% endfor %}
{% for allocation in item.allocations.all %}
{% object_link 'build-detail' allocation.build.id allocation.build %}
{% decimal allocation.quantity as qty %}
{% trans "This stock item is allocated to Build Order" %} {{ link }} {% if qty < item.quantity %}({% trans "Quantity" %}: {{ qty }}){% endif %}
{% endfor %}
{% if item.serialized %}
{% trans "This stock item is serialized - it has a unique serial number and the quantity cannot be adjusted." %}
{% endif %}
{% endblock details %}
{% block details_right %}
{% endblock details_right %}
{% block js_ready %}
{{ block.super }}
$("#stock-serialize").click(function() {
serializeStockItem({{ item.pk }}, {
part: {{ item.part.pk }},
reload: true,
data: {
quantity: {{ item.quantity|unlocalize }},
{% if item.location %}
destination: {{ item.location.pk }},
{% elif item.part.default_location %}
destination: {{ item.part.default_location.pk }},
{% endif %}
}
});
});
$('#stock-install-in').click(function() {
// TODO - Launch dialog to install this item *into* another stock item
});
$('#stock-uninstall').click(function() {
launchModalForm(
"{% url 'stock-item-uninstall' %}",
{
data: {
'items[]': [{{ item.pk }}],
},
reload: true,
}
);
});
$("#stock-test-report").click(function() {
printTestReports([{{ item.pk }}]);
});
$("#print-label").click(function() {
printStockItemLabels([{{ item.pk }}]);
});
{% if roles.stock.change %}
$("#stock-duplicate").click(function() {
// Duplicate a stock item
duplicateStockItem({{ item.pk }}, {
follow: true,
});
});
$('#stock-edit').click(function() {
editStockItem({{ item.pk }}, {
reload: true,
});
});
$('#stock-edit-status').click(function () {
constructForm('{% url "api-stock-detail" item.pk %}', {
fields: {
status: {},
},
reload: true,
title: '{% trans "Edit Stock Status" %}',
});
});
{% endif %}
$("#show-qr-code").click(function() {
launchModalForm("{% url 'stock-item-qr' item.id %}",
{
no_post: true,
});
});
$("#barcode-link").click(function() {
linkBarcodeDialog({{ item.id }});
});
$("#barcode-unlink").click(function() {
unlinkBarcode({{ item.id }});
});
$("#barcode-scan-into-location").click(function() {
scanItemsIntoLocation([{{ item.id }}]);
});
function itemAdjust(action) {
inventreeGet(
'{% url "api-stock-detail" item.pk %}',
{
part_detail: true,
location_detail: true,
},
{
success: function(item) {
adjustStock(action, [item], {
success: function() {
location.reload();
}
});
}
}
);
}
$('#stock-add').click(function() {
itemAdjust('add');
});
$("#stock-delete").click(function () {
launchModalForm(
"{% url 'stock-item-delete' item.id %}",
{
redirect: "{% url 'part-detail' item.part.id %}"
}
);
});
{% if item.part.can_convert %}
$("#stock-convert").click(function() {
launchModalForm("{% url 'stock-item-convert' item.id %}",
{
reload: true,
}
);
});
{% endif %}
{% if item.in_stock %}
$("#stock-assign-to-customer").click(function() {
inventreeGet('{% url "api-stock-detail" item.pk %}', {}, {
success: function(response) {
assignStockToCustomer(
[response],
{
success: function() {
location.reload();
},
}
);
}
});
});
$("#stock-move").click(function() {
itemAdjust("move");
});
$("#stock-count").click(function() {
itemAdjust('count');
});
$('#stock-remove').click(function() {
itemAdjust('take');
});
{% else %}
$("#stock-return-from-customer").click(function() {
launchModalForm("{% url 'stock-item-return' item.id %}",
{
reload: true,
}
);
});
{% endif %}
$('#serial-number-search').click(function() {
findStockItemBySerialNumber({{ item.part.pk }});
});
enableBreadcrumbTree({
label: 'stockitem',
url: '{% url "api-location-tree" %}',
{% if item.location %}
selected: {{ item.location.pk }},
{% endif %}
processNode: function(node) {
node.text = node.name;
node.href = `/stock/location/${node.pk}/`;
return node;
}
});
{% endblock %}