{% extends "stock/item_base.html" %} {% load static %} {% load inventree_extras %} {% load i18n %} {% load l10n %} {% load markdownify %} {% block sidebar %} {% include "stock/stock_sidebar.html" %} {% endblock %} {% block page_content %}

{% trans "Stock Tracking Information" %}

{% include "spacer.html" %}
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %} {% if owner_control.value == "True" %} {% authorized_owners item.owner as owners %} {% endif %} {% if owner_control.value == "False" or owner_control.value == "True" and user in owners %} {% if roles.stock.change and not item.is_building %} {% endif %} {% endif %}

{% trans "Child Stock Items" %}

{% if item.child_count > 0 %} {% include "stock_table.html" with prefix="childs-" %} {% else %}
{% trans "This stock item does not have any child items" %}
{% endif %}

{% trans "Test Data" %}

{% include "spacer.html" %}
{% if user.is_staff %} {% endif %}
{% include "filter_list.html" with id="stocktests" %}

{% trans "Attachments" %}

{% include "spacer.html" %}
{% include "attachment_button.html" %}
{% include "attachment_table.html" %}

{% trans "Stock Item Notes" %}

{% if item.notes %} {{ item.notes | markdownify }} {% endif %}

{% trans "Installed Stock Items" %}

{% include "spacer.html" %}
{% endblock %} {% block js_ready %} {{ block.super }} $('#stock-item-install').click(function() { launchModalForm( "{% url 'stock-item-install' item.pk %}", { data: { 'part': {{ item.part.pk }}, 'install_item': true, }, reload: true, } ); }); loadInstalledInTable( $('#installed-table'), { stock_item: {{ item.pk }}, part: {{ item.part.pk }}, quantity: {{ item.quantity|unlocalize }}, } ); $('#multi-item-uninstall').click(function() { var selections = $('#installed-table').bootstrapTable('getSelections'); var items = []; selections.forEach(function(item) { items.push(item.pk); }); launchModalForm( "{% url 'stock-item-uninstall' %}", { data: { 'items[]': items, }, reload: true, } ); }); $('#edit-notes').click(function() { constructForm('{% url "api-stock-detail" item.pk %}', { fields: { notes: { multiline: true, } }, title: '{% trans "Edit Notes" %}', reload: true, }); }); enableDragAndDrop( '#attachment-dropzone', "{% url 'api-stock-attachment-list' %}", { data: { stock_item: {{ item.id }}, }, label: 'attachment', success: function(data, status, xhr) { reloadAttachmentTable(); } } ); loadAttachmentTable( '{% url "api-stock-attachment-list" %}', { filters: { stock_item: {{ item.pk }}, }, onEdit: function(pk) { var url = `/api/stock/attachment/${pk}/`; constructForm(url, { fields: { filename: {}, comment: {}, }, title: '{% trans "Edit Attachment" %}', onSuccess: reloadAttachmentTable }); }, onDelete: function(pk) { var url = `/api/stock/attachment/${pk}/`; constructForm(url, { method: 'DELETE', confirmMessage: '{% trans "Confirm Delete Operation" %}', title: '{% trans "Delete Attachment" %}', onSuccess: reloadAttachmentTable, }); } } ); $("#new-attachment").click(function() { constructForm( '{% url "api-stock-attachment-list" %}', { method: 'POST', fields: { attachment: {}, comment: {}, stock_item: { value: {{ item.pk }}, hidden: true, }, }, reload: true, title: '{% trans "Add Attachment" %}', } ); }); loadStockTestResultsTable( $("#test-result-table"), { part: {{ item.part.id }}, stock_item: {{ item.id }}, } ); function reloadTable() { $("#test-result-table").bootstrapTable("refresh"); } {% if item.has_test_reports %} $("#test-report").click(function() { printTestReports([{{ item.pk }}]); }); {% endif %} {% if user.is_staff %} $("#delete-test-results").click(function() { launchModalForm( "{% url 'stock-item-delete-test-data' item.id %}", { success: reloadTable, } ); }); {% endif %} $("#add-test-result").click(function() { constructForm('{% url "api-stock-test-result-list" %}', { method: 'POST', fields: { test: {}, result: {}, value: {}, attachment: {}, notes: {}, stock_item: { value: {{ item.pk }}, hidden: true, } }, title: '{% trans "Add Test Result" %}', onSuccess: reloadTable, }); }); $("#test-result-table").on('click', '.button-test-add', function() { var button = $(this); var test_name = button.attr('pk'); constructForm('{% url "api-stock-test-result-list" %}', { method: 'POST', fields: { test: { value: test_name, }, result: {}, value: {}, attachment: {}, notes: {}, stock_item: { value: {{ item.pk }}, hidden: true, } }, title: '{% trans "Add Test Result" %}', onSuccess: reloadTable, }); }); $("#test-result-table").on('click', '.button-test-edit', function() { var button = $(this); var pk = button.attr('pk'); var url = `/api/stock/test/${pk}/`; constructForm(url, { fields: { test: {}, result: {}, value: {}, attachment: {}, notes: {}, }, title: '{% trans "Edit Test Result" %}', onSuccess: reloadTable, }); }); $("#test-result-table").on('click', '.button-test-delete', function() { var button = $(this); var pk = button.attr('pk'); var url = `/api/stock/test/${pk}/`; constructForm(url, { method: 'DELETE', title: '{% trans "Delete Test Result" %}', onSuccess: reloadTable, }); }); {% if item.child_count > 0 %} loadStockTable($("#childs-stock-table"), { params: { location_detail: true, part_detail: false, ancestor: {{ item.id }}, }, name: 'item-childs', groupByField: 'location', buttons: [ '#stock-options', ], url: "{% url 'api-stock-list' %}", }); {% endif %} $("#new-entry").click(function() { launchModalForm( "{% url 'stock-tracking-create' item.id %}", { reload: true, } ); }); loadStockTrackingTable($("#track-table"), { params: { ordering: '-date', item: {{ item.pk }}, user_detail: true, }, url: "{% url 'api-stock-tracking-list' %}", }); enableSidebar('stockitem'); {% endblock %}