{% extends "order/sales_order_base.html" %} {% load inventree_extras %} {% load status_codes %} {% load i18n %} {% load static %} {% block details %} {% include 'order/so_tabs.html' with tab='details' %}

{% trans "Sales Order Items" %}

{% endblock %} {% block js_ready %} {{ block.super }} $("#new-so-line").click(function() { launchModalForm("{% url 'so-line-item-create' %}", { reload: true, data: { order: {{ order.id }}, }, secondary: [ ] }); }); $("#so-lines-table").inventreeTable({ formatNoMatches: function() { return "No matching line items"; }, queryParams: { order: {{ order.id }}, part_detail: true, }, url: "{% url 'api-so-line-list' %}", detailView: true, detailFilter: function(index, row) { return row.allocated > 0; }, detailFormatter: function(index, row, element) { inventreeGet("{% url 'api-stock-list' %}", { location_detail: true, sales_order_line: row.pk, }, { success: function(response) { var html = `
`; element.html(html); $(`#allocation-table-${row.pk}`).bootstrapTable({ data: response, showHeader: false, columns: [ { width: '50%', field: 'quantity', title: 'Quantity', formatter: function(value, row, index, field) { var html = ''; if (row.serial && row.quantity == 1) { html = `Serial Number: ${row.serial}`; } else { html = `Quantity: ${row.quantity}`; } return renderLink(html, `/stock/item/${row.pk}/`); }, }, { field: 'location', title: 'Location', formatter: function(value, row, index, field) { return renderLink(row.location_detail.pathstring, `/stock/location/${row.location}/`); }, }, { field: 'buttons', title: 'Actions', formatter: function(value, row, index, field) { return ''; }, }, ], }); }, error: function(response) { console.log("An error!"); }, } ); return "{% trans 'Loading data' %}"; }, columns: [ { field: 'pk', title: 'ID', visible: false, }, { sortable: true, field: 'part', title: 'Part', formatter: function(value, row, index, field) { if (row.part) { return imageHoverIcon(row.part_detail.thumbnail) + renderLink(row.part_detail.full_name, `/part/${value}/`); } else { return '-'; } } }, { sortable: true, field: 'reference', title: 'Reference' }, { sortable: true, field: 'quantity', title: 'Quantity', formatter: function(value, row, index, field) { return makeProgressBar(row.allocated, row.quantity); }, sorter: function(valA, valB, rowA, rowB) { if (rowA.allocated == 0 && rowB.allocated == 0) { return (rowA.quantity > rowB.quantity) ? 1 : -1; } var progressA = rowA.allocated / rowA.quantity; var progressB = rowB.allocated / rowA.quantity; return (progressA < progressB) ? 1 : -1; } }, { field: 'notes', title: 'Notes', }, { field: 'buttons', formatter: function(value, row, index, field) { return '-'; } }, ], }); {% endblock %}