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

{% trans "Stock Tracking Information" %}

{% include "spacer.html" %}
{% include "filter_list.html" with id="stocktracking" %}
{% if item.part.component %}

{% trans "Build Order Allocations" %}

{% include "spacer.html" %}
{% include "filter_list.html" with id="buildorderallocation" %}
{% endif %} {% if item.part.salable %}

{% trans "Sales Order Allocations" %}

{% include "spacer.html" %}
{% include "filter_list.html" with id="salesorderallocation" %}
{% endif %}

{% trans "Child Stock Items" %}

{% include "spacer.html" %}
{% if item.child_count > 0 %} {% include "filter_list.html" with id="stock-childs" %} {% 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" %}

{% include "spacer.html" %}
{% include "notes_buttons.html" %}

{% trans "Installed Stock Items" %}

{% include "spacer.html" %}
{% if roles.stock.add %} {% endif %}
{% include "filter_list.html" with id='installed-items' %}
{% endblock page_content %} {% block js_ready %} {{ block.super }} // Load the "allocations" tab onPanelLoad('allocations', function() { {% if item.part.component %} loadBuildOrderAllocationTable('#build-order-allocation-table', { params: { stock_item: {{ item.pk }}, } }); {% endif %} {% if item.part.salable %} loadSalesOrderAllocationTable('#sales-order-allocation-table', { params: { stock_item: {{ item.pk }}, } }); {% endif %} }); $('#stock-item-install').click(function() { {% settings_value "STOCK_ENFORCE_BOM_INSTALLATION" as enforce_bom %} installStockItem({{ item.pk }}, {{ item.part.pk }}, { enforce_bom: {% js_bool enforce_bom %}, onSuccess: function(response) { $("#installed-table").bootstrapTable('refresh'); } }); }); loadInstalledInTable( $('#installed-table'), { stock_item: {{ item.pk }}, part: {{ item.part.pk }}, quantity: {{ item.quantity|unlocalize }}, can_edit: {% js_bool roles.stock.change %}, } ); onPanelLoad('notes', function() { setupNotesField( 'stock-notes', '{% url "api-stock-detail" item.pk %}', { model_type: 'stockitem', model_id: {{ item.pk }}, {% if roles.stock.change and user_owns_item %} editable: true, {% else %} editable: false, {% endif %} } ); }); onPanelLoad('attachments', function() { loadAttachmentTable('stockitem', {{ item.pk }}); }); {% settings_value "TEST_STATION_DATA" as test_station_fields %} {% if item.part.trackable %} loadStockTestResultsTable( $("#test-result-table"), { part: {{ item.part.id }}, stock_item: {{ item.id }}, test_station_fields: {% js_bool test_station_fields %} } ); $("#test-report").click(function() { printReports('stockitem', [{{ item.pk }}]); }); {% endif %} {% if user.is_staff %} $("#delete-test-results").click(function() { var url = '{% url "api-stock-test-result-list" %}'; inventreeGet( url, { stock_item: {{ item.pk }}, }, { success: function(response) { var items = []; // Ensure that we are only deleting the correct test results response.forEach(function(result) { items.push(result.pk); }); var html = `
{% trans "Delete all test results for this stock item" %}
`; constructForm(url, { form_data: { items: items, filters: { stock_item: {{ item.pk }}, } }, multi_delete: true, method: 'DELETE', title: '{% trans "Delete Test Data" escape %}', preFormContent: html, refreshTable: '#test-result-table', }); } } ); }); {% endif %} $("#add-test-result").click(function() { constructForm('{% url "api-stock-test-result-list" %}', { method: 'POST', fields: stockItemTestResultFields({ part: {{ item.part.pk }}, stock_item: {{ item.pk }}, }), title: '{% trans "Add Test Result" escape %}', refreshTable: '#test-result-table', }); }); {% if item.child_count > 0 %} loadStockTable($("#childs-stock-table"), { params: { ancestor: {{ item.id }}, }, name: 'item-childs', filterTarget: '#filter-list-stock-childs', filterKey: 'stock', }); {% endif %} loadStockTrackingTable($("#track-table"), { params: { ordering: '-date', item: {{ item.pk }}, user_detail: true, }, url: "{% url 'api-stock-tracking-list' %}", }); enableSidebar('stockitem'); {% endblock js_ready %}