{% extends "part/part_base.html" %} {% load static %} {% load i18n %} {% load inventree_extras %} {% load crispy_forms_tags %} {% block sidebar %} {% include 'part/part_sidebar.html' %} {% endblock sidebar %} {% block breadcrumb_tree %} {% endblock breadcrumb_tree %} {% block page_content %}

{% trans "Part Stock" %}

{% include "spacer.html" %}
{% if roles.stock.add and not part.virtual %} {% endif %}
{% include "stock_table.html" %}
{% settings_value 'DISPLAY_SCHEDULE_TAB' user=request.user as show_scheduling %} {% if show_scheduling %}

{% trans "Part Scheduling" %}

{% include "spacer.html" %}
{% include "part/part_scheduling.html" %}
{% endif %} {% settings_value 'STOCKTAKE_ENABLE' as stocktake_enable %} {% settings_value 'DISPLAY_STOCKTAKE_TAB' user=request.user as show_stocktake %} {% if stocktake_enable and show_stocktake %}

{% trans "Part Stocktake" %}

{% include "spacer.html" %}
{% if roles.stocktake.add %} {% endif %}
{% include "part/part_stocktake.html" %}
{% endif %}

{% trans "Part Test Templates" %}

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

{% trans "Purchase Orders" %}

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

{% trans "Sales Orders" %}

{% include "filter_list.html" with id="salesorder" %}

{% trans "Sales Order Allocations" %}

{% include "filter_list.html" with id="salesorderallocation" %}
{% include "part/prices.html" %}

{% trans "Part Notes" %}

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

{% trans "Part Variants" %}

{% include "spacer.html" %}
{% if part.is_template and part.active %} {% endif %}
{% include "filter_list.html" with id="variants" %}

{% trans "Parameters" %}

{% include "spacer.html" %}
{% if roles.part.add %} {% endif %}
{% include "filter_list.html" with id="parameters" %}

{% trans "Attachments" %}

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

{% trans "Bill of Materials" %}

{% include "spacer.html" %}
{% if roles.part.change %} {% endif %}
{% include "part/bom.html" with part=part %}

{% trans "Assemblies" %}

{% include "filter_list.html" with id="usedin" %}
{% if part.assembly %}

{% trans "Part Builds" %}

{% include "spacer.html" %}
{% if part.active %} {% if roles.build.add %} {% endif %} {% endif %}
{% include "filter_list.html" with id="build" %}
{% endif %} {% if part.component %}

{% trans "Build Order Allocations" %}

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

{% trans "Part Suppliers" %}

{% include "spacer.html" %}
{% include "filter_list.html" with id="supplier-part" %}

{% trans "Part Manufacturers" %}

{% include "spacer.html" %}
{% include "filter_list.html" with id="manufacturer-part" %}
{% endblock page_content %} {% block js_load %} {{ block.super }} {% endblock js_load %} {% block js_ready %} {{ block.super }} // Load the "notes" tab onPanelLoad('part-notes', function() { setupNotesField( 'part-notes', '{% url "api-part-detail" part.pk %}', { model_type: "part", model_id: {{ part.pk }}, editable: {% js_bool roles.part.change %}, } ); }); // Load the "scheduling" tab onPanelLoad('scheduling', function() { var chart = loadPartSchedulingChart('part-schedule-chart', {{ part.pk }}); $('#btn-schedule-reload').click(function() { if (chart != null) { chart.destroy(); } chart = loadPartSchedulingChart('part-schedule-chart', {{ part.pk }}); }); }); // Load the "stocktake" tab onPanelLoad('stocktake', function() { loadPartStocktakeTable({{ part.pk }}, { allow_edit: {% js_bool roles.stocktake.change %}, allow_delete: {% js_bool roles.stocktake.delete %}, }); {% if roles.stocktake.add %} $('#btn-stocktake').click(function() { generateStocktakeReport({ part: { value: {{ part.pk }} }, location: { tree_picker: { url: '{% url "api-location-tree" %}', }, }, generate_report: { value: false, }, update_parts: {}, }); }); {% endif %} }); // Load the "suppliers" tab onPanelLoad('suppliers', function() { function reloadSupplierPartTable() { $('#supplier-part-table').bootstrapTable('refresh'); } $('#supplier-create').click(function () { createSupplierPart({ part: {{ part.pk }}, onSuccess: reloadSupplierPartTable, }); }); $("#supplier-part-delete").click(function() { var selections = getTableData('#supplier-part-table'); deleteSupplierParts(selections, { success: reloadSupplierPartTable, }); }); loadSupplierPartTable( "#supplier-part-table", "{% url 'api-supplier-part-list' %}", { params: { part: {{ part.id }}, part_detail: true, supplier_detail: true, manufacturer_detail: true, }, } ); loadManufacturerPartTable( '#manufacturer-part-table', "{% url 'api-manufacturer-part-list' %}", { params: { part: {{ part.id }}, part_detail: true, manufacturer_detail: true, }, } ); $("#manufacturer-part-delete").click(function() { var selectionss = getTableData('#manufacturer-part-table'); deleteManufacturerParts(selections, { success: function() { $("#manufacturer-part-table").bootstrapTable('refresh'); } }); }); $('#manufacturer-create').click(function () { createManufacturerPart({ part: {{ part.pk }}, onSuccess: function() { $("#manufacturer-part-table").bootstrapTable('refresh'); } }); }); }); // Load the "builds" tab onPanelLoad("build-orders", function() { {% if part.assembly %} $("#start-build").click(function() { newBuildOrder({ part: {{ part.pk }}, }); }); loadBuildTable($("#build-table"), { locale: '{{ request.LANGUAGE_CODE }}', params: { part: {{ part.id }}, } }); {% endif %} {% if part.component %} loadBuildOrderAllocationTable("#build-order-allocation-table", { params: { part: {{ part.id }}, } }); {% endif %} }); // Load the "sales orders" tab onPanelLoad("sales-orders", function() { loadSalesOrderAllocationTable("#sales-order-allocation-table", { params: { part: {{ part.id }}, } }); }); // Load the "used in" tab onPanelLoad("used-in", function() { loadUsedInTable( '#used-table', {{ part.pk }}, ); }); // Load the "BOM" tab onPanelLoad("bom", function() { // Load the BOM table data loadBomTable($("#bom-table"), { {% if roles.part.change %} editable: true, {% else %} editable: false, {% endif %} bom_url: "{% url 'api-bom-list' %}", part_url: "{% url 'api-part-list' %}", parent_id: {{ part.id }} , sub_part_detail: true, }); $('#bom-item-delete').click(function() { // Get a list of the selected BOM items var rows = getTableData('#bom-table'); deleteBomItems(rows, { success: function() { $('#bom-table').bootstrapTable('refresh'); } }); }); $('#bom-upload').click(function() { location.href = "{% url 'upload-bom' part.id %}"; }); $('#bom-duplicate').click(function() { duplicateBom({{ part.pk }}, { success: function(response) { $('#bom-table').bootstrapTable('refresh'); } }); }); $("[id^=bom-item-new]").click(function () { addBomItem({{ part.pk }}, { onSuccess: function() { $('#bom-table').bootstrapTable('refresh'); } }); }); $("#validate-bom").click(function() { validateBom({{ part.id }}, { reload: true }); }); $("#download-bom").click(function () { exportBom({{ part.id }}); }); {% if report_enabled %} $("#print-bom-report").click(function() { printReports('part', [{{ part.pk }}]); }); {% endif %} }); // Load the "related parts" tab onPanelLoad("related-parts", function() { loadRelatedPartsTable( "#related-parts-table", {{ part.pk }} ); $("#add-related-part").click(function() { constructForm('{% url "api-part-related-list" %}', { method: 'POST', fields: { part_1: { hidden: true, value: {{ part.pk }}, }, part_2: { label: '{% trans "Related Part" escape %}', filters: { exclude_id: {{ part.pk }}, exclude_related: {{ part.pk }}, } } }, focus: 'part_2', title: '{% trans "Add Related Part" escape %}', refreshTable: '#related-parts-table', }); }); $('.delete-related-part').click(function() { var button = $(this); launchModalForm(button.attr('url'), { reload: true, }); }); }); // Load the "variants" tab onPanelLoad("variants", function() { loadPartVariantTable($('#variants-table'), {{ part.pk }}); $('#new-variant').click(function() { duplicatePart( {{ part.pk }}, { variant: true, } ); }); }); onPanelLoad("purchase-orders", function() { loadPartPurchaseOrderTable( "#purchase-order-table", {{ part.pk }}, ); }); onPanelLoad("sales-orders", function() { loadSalesOrderTable($("#sales-order-table"), { url: "{% url 'api-so-list' %}", params: { part: {{ part.id }}, }, }); }); $("#part-order2").click(function() { inventreeGet( '{% url "api-part-detail" part.pk %}', {}, { success: function(part) { orderParts( [part], { onSuccess: function() { $("#purchase-order-table").bootstrapTable('refresh'); } } ); } } ); }); onPanelLoad("test-templates", function() { // Load test template table loadPartTestTemplateTable( $("#test-template-table"), { part: {{ part.pk }}, params: { part: {{ part.pk }}, } } ); // Callback for "add test template" button $("#add-test-template").click(function() { constructForm('{% url "api-part-test-template-list" %}', { method: 'POST', fields: partTestTemplateFields({ part: {{ part.pk }} }), title: '{% trans "Add Test Result Template" escape %}', refreshTable: '#test-template-table', }); }); }); onPanelLoad("part-stock", function() { $('#new-stock-item').click(function () { createNewStockItem({ data: { part: {{ part.id }}, {% if part.default_location %} location: {{ part.default_location.pk }}, {% endif %} } }); }); loadStockTable($("#stock-table"), { params: { part: {{ part.id }}, location_detail: true, part_detail: true, supplier_part_detail: true, }, }); $('#item-create').click(function () { createNewStockItem({ data: { part: {{ part.id }}, } }); }); }); onPanelLoad("part-parameters", function() { loadPartParameterTable( '#parameter-table', { params: { part: {{ part.pk }}, } } ); {% if roles.part.add %} $('#param-create').click(function() { createPartParameter({{ part.pk }}, { refreshTable: '#parameter-table' }); }); {% endif %} }); onPanelLoad("part-attachments", function() { loadAttachmentTable('part', {{ part.pk }}); }); onPanelLoad('pricing', function() { {% include "part/pricing_javascript.html" %} }); enableSidebar('part'); enableBreadcrumbTree({ label: 'part', url: '{% url "api-part-category-tree" %}', {% if part.category %} selected: {{ part.category.pk }}, {% endif %} processNode: function(node) { node.text = node.name; node.href = `/part/category/${node.pk}/`; return node; } }); {% endblock js_ready %}