{% extends "build/build_base.html" %} {% load static %} {% load i18n %} {% load inventree_extras %} {% load status_codes %} {% load markdownify %} {% block sidebar %} {% include "build/sidebar.html" %} {% endblock %} {% block page_content %}

{% trans "Build Details" %}

{% if build.active and build.has_untracked_bom_items %} {% endif %} {% if build.batch %} {% endif %} {% if build.parent %} {% endif %} {% if build.sales_order %} {% endif %} {% if build.link %} {% endif %} {% if build.issued_by %} {% endif %} {% if build.responsible %} {% endif %}
{% trans "Description" %} {{ build.title }}{% include "clip.html"%}
{% trans "Part" %} {{ build.part.full_name }}{% include "clip.html"%}
{% trans "Quantity" %}{{ build.quantity }}
{% trans "Stock Source" %} {% if build.take_from %} {{ build.take_from }}{% include "clip.html"%} {% else %} {% trans "Stock can be taken from any available location." %} {% endif %}
{% trans "Destination" %} {% if build.destination %} {{ build.destination }} {% include "clip.html"%} {% else %} {% trans "Destination location not specified" %} {% endif %}
{% trans "Status" %} {% build_status_label build.status %}
{% trans "Completed" %} {% progress_bar build.completed build.quantity id='build-completed-2' max_width='150px' %}
{% trans "Allocated Parts" %}
{% trans "Batch" %} {{ build.batch }}{% include "clip.html"%}
{% trans "Parent Build" %} {{ build.parent }}{% include "clip.html"%}
{% trans "Sales Order" %} {{ build.sales_order }}{% include "clip.html"%}
{% trans "External Link" %} {{ build.link }}{% include "clip.html"%}
{% trans "Issued By" %} {{ build.issued_by }}
{% trans "Responsible" %} {{ build.responsible }}
{% if build.target_date %} {% else %} {% endif %} {% if build.completion_date %} {% else %} {% endif %}
{% trans "Created" %} {{ build.creation_date }}
{% trans "Target Date" %} {{ build.target_date }}{% if build.is_overdue %} {% endif %} {% trans "No target date set" %}
{% trans "Completed" %}{{ build.completion_date }}{% if build.completed_by %}{{ build.completed_by }}{% endif %}{% trans "Build not complete" %}

{% trans "Child Build Orders" %}

{% include "filter_list.html" with id='sub-build' %}

{% trans "Allocate Stock to Build" %}

{% include "spacer.html" %}
{% if build.active and build.has_untracked_bom_items %} {% endif %}
{% if build.has_untracked_bom_items %} {% if build.active %} {% if build.areUntrackedPartsFullyAllocated %}
{% trans "Untracked stock has been fully allocated for this Build Order" %}
{% else %}
{% trans "Untracked stock has not been fully allocated for this Build Order" %}
{% endif %} {% endif %}
{% include "filter_list.html" with id='builditems' %}
{% else %}
{% trans "This Build Order does not have any associated untracked BOM items" %}
{% endif %}

{% trans "Incomplete Build Outputs" %}

{% include "spacer.html" %}
{% if build.active %} {% endif %}
{% if build.active %}
{% include "filter_list.html" with id='incompletebuilditems' %}
{% endif %}

{% trans "Completed Build Outputs" %}

{% include "stock_table.html" with read_only=True prefix="build-" %}

{% trans "Attachments" %}

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

{% trans "Build Notes" %}

{% if build.notes %} {{ build.notes | markdownify }} {% endif %}
{% endblock %} {% block js_ready %} {{ block.super }} $('#btn-create-output').click(function() { launchModalForm('{% url "build-output-create" build.id %}', { reload: true, } ); }); loadStockTable($("#build-stock-table"), { params: { location_detail: true, part_detail: true, build: {{ build.id }}, is_building: false, }, groupByField: 'location', buttons: [ '#stock-options', ], url: "{% url 'api-stock-list' %}", }); // Get the list of BOM items required for this build inventreeGet( '{% url "api-bom-list" %}', { part: {{ build.part.pk }}, sub_part_detail: true, }, { success: function(response) { var build_info = { pk: {{ build.pk }}, part: {{ build.part.pk }}, quantity: {{ build.quantity }}, bom_items: response, {% if build.take_from %} source_location: {{ build.take_from.pk }}, {% endif %} {% if build.has_tracked_bom_items %} tracked_parts: true, {% else %} tracked_parts: false, {% endif %} }; {% if build.active %} loadBuildOutputTable(build_info); linkButtonsToSelection( '#build-output-table', [ '#output-options', '#multi-output-complete', ] ); $('#multi-output-complete').click(function() { var outputs = $('#build-output-table').bootstrapTable('getSelections'); completeBuildOutputs( build_info.pk, outputs, { success: function() { // Reload the "in progress" table $('#build-output-table').bootstrapTable('refresh'); // Reload the "completed" table $('#build-stock-table').bootstrapTable('refresh'); } } ); }); {% endif %} {% if build.active and build.has_untracked_bom_items %} // Load allocation table for un-tracked parts loadBuildOutputAllocationTable( build_info, null, { search: true, } ); {% endif %} } } ); loadBuildTable($('#sub-build-table'), { url: '{% url "api-build-list" %}', filterTarget: "#filter-list-sub-build", params: { ancestor: {{ build.pk }}, } }); enableDragAndDrop( '#attachment-dropzone', '{% url "api-build-attachment-list" %}', { data: { build: {{ build.id }}, }, label: 'attachment', success: function(data, status, xhr) { location.reload(); } } ); loadAttachmentTable('{% url "api-build-attachment-list" %}', { filters: { build: {{ build.pk }}, }, fields: { build: { value: {{ build.pk }}, hidden: true, } } }); $('#edit-notes').click(function() { constructForm('{% url "api-build-detail" build.pk %}', { fields: { notes: { multiline: true, } }, title: '{% trans "Edit Notes" %}', reload: true, }); }); function reloadTable() { $('#allocation-table-untracked').bootstrapTable('refresh'); } {% if build.active %} $("#btn-auto-allocate").on('click', function() { var bom_items = $("#allocation-table-untracked").bootstrapTable("getData"); var incomplete_bom_items = []; bom_items.forEach(function(bom_item) { if (bom_item.required > bom_item.allocated) { incomplete_bom_items.push(bom_item); } }); if (incomplete_bom_items.length == 0) { showAlertDialog( '{% trans "Allocation Complete" %}', '{% trans "All untracked stock items have been allocated" %}', ); } else { allocateStockToBuild( {{ build.pk }}, {{ build.part.pk }}, incomplete_bom_items, { {% if build.take_from %} source_location: {{ build.take_from.pk }}, {% endif %} success: function(data) { $('#allocation-table-untracked').bootstrapTable('refresh'); } } ); } }); $('#btn-unallocate').on('click', function() { unallocateStock({{ build.id }}, { table: '#allocation-table-untracked', }); }); $('#allocate-selected-items').click(function() { var bom_items = $("#allocation-table-untracked").bootstrapTable("getSelections"); if (bom_items.length == 0) { bom_items = $("#allocation-table-untracked").bootstrapTable('getData'); } allocateStockToBuild( {{ build.pk }}, {{ build.part.pk }}, bom_items, { {% if build.take_from %} source_location: {{ build.take_from.pk }}, {% endif %} success: function(data) { $('#allocation-table-untracked').bootstrapTable('refresh'); } } ); }); $("#btn-order-parts").click(function() { launchModalForm("/order/purchase-order/order-parts/", { data: { build: {{ build.id }}, }, }); }); {% endif %} enableSidebar('buildorder'); {% endblock %}