{% extends "page_base.html" %}
{% load static %}
{% load i18n %}
{% load inventree_extras %}
{% block page_title %}
{% inventree_title %} | {% trans "Supplier Part" %}
{% endblock page_title %}
{% block sidebar %}
{% include "company/supplier_part_sidebar.html" %}
{% endblock sidebar %}
{% block breadcrumbs %}
{% trans "Suppliers" %}
{% if part.supplier %}
{{ part.supplier.name }}
{% endif %}
{{ part.SKU }}
{% endblock breadcrumbs %}
{% block heading %}
{% trans "Supplier Part" %}: {{ part.SKU }}
{% endblock heading %}
{% block actions %}
{% if user.is_staff and perms.company.change_company %}
{% url 'admin:company_supplierpart_change' part.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
{% if roles.purchase_order.add %}
{% endif %}
{% if roles.purchase_order.delete %}
{% endif %}
{% endblock actions %}
{% block thumbnail %}
{% endblock %}
{% block details %}
|
{% trans "Internal Part" %} |
{% if part.part %}
{{ part.part.full_name }}{% include "clip.html"%}
{% endif %}
|
{% if part.description %}
|
{% trans "Description" %} |
{{ part.description }}{% include "clip.html"%} |
{% endif %}
{% endblock details %}
{% block details_right %}
|
{% trans "Supplier" %} |
{{ part.supplier.name }}{% include "clip.html"%} |
|
{% trans "SKU" %} |
{{ part.SKU }}{% include "clip.html"%} |
{% if part.manufacturer_part.manufacturer %}
|
{% trans "Manufacturer" %} |
{{ part.manufacturer_part.manufacturer.name }}{% include "clip.html"%} |
{% endif %}
{% if part.manufacturer_part.MPN %}
|
{% trans "MPN" %} |
{{ part.manufacturer_part.MPN }}{% include "clip.html"%} |
{% endif %}
{% if part.packaging %}
|
{% trans "Packaging" %} |
{{ part.packaging }}{% include "clip.html"%} |
{% endif %}
{% if part.note %}
|
{% trans "Note" %} |
{{ part.note }}{% include "clip.html"%} |
{% endif %}
{% if part.link %}
|
{% trans "External Link" %} |
{{ part.link }}{% include "clip.html"%} |
{% endif %}
{% endblock %}
{% block page_content %}
{% trans "Supplier Part Stock" %}
{% include "spacer.html" %}
{% include "stock_table.html" %}
{% trans "Supplier Part Orders" %}
{% include "spacer.html" %}
{% if roles.purchase_order.add %}
{% endif %}
{% trans "Pricing Information" %}
{% include "spacer.html" %}
{% if roles.purchase_order.add %}
{% endif %}
{% endblock %}
{% block js_ready %}
{{ block.super }}
function reloadPriceBreaks() {
$("#price-break-table").bootstrapTable("refresh");
}
$('#price-break-table').inventreeTable({
name: 'buypricebreaks',
formatNoMatches: function() { return "{% trans "No price break information found" %}"; },
queryParams: {
part: {{ part.id }},
},
url: "{% url 'api-part-supplier-price-list' %}",
onPostBody: function() {
var table = $('#price-break-table');
table.find('.button-price-break-delete').click(function() {
var pk = $(this).attr('pk');
constructForm(`/api/company/price-break/${pk}/`, {
method: 'DELETE',
onSuccess: reloadPriceBreaks,
title: '{% trans "Delete Price Break" %}',
});
});
table.find('.button-price-break-edit').click(function() {
var pk = $(this).attr('pk');
constructForm(`/api/company/price-break/${pk}/`, {
fields: {
quantity: {},
price: {},
price_currency: {},
},
onSuccess: reloadPriceBreaks,
title: '{% trans "Edit Price Break" %}',
});
});
},
columns: [
{
field: 'pk',
title: 'ID',
visible: false,
switchable: false,
},
{
field: 'quantity',
title: '{% trans "Quantity" %}',
sortable: true,
},
{
field: 'price',
title: '{% trans "Price" %}',
sortable: true,
formatter: function(value, row, index) {
var html = value;
html += ``
html += makeIconButton('fa-edit icon-blue', 'button-price-break-edit', row.pk, '{% trans "Edit price break" %}');
html += makeIconButton('fa-trash-alt icon-red', 'button-price-break-delete', row.pk, '{% trans "Delete price break" %}');
html += `
`;
return html;
}
},
]
});
$('#new-price-break').click(function() {
constructForm(
'{% url "api-part-supplier-price-list" %}',
{
method: 'POST',
fields: {
quantity: {},
part: {
value: {{ part.pk }},
hidden: true,
},
price: {},
price_currency: {
},
},
title: '{% trans "Add Price Break" %}',
onSuccess: reloadPriceBreaks,
}
);
});
loadPurchaseOrderTable($("#purchase-order-table"), {
url: "{% url 'api-po-list' %}?supplier_part={{ part.id }}",
});
loadStockTable($("#stock-table"), {
params: {
supplier_part: {{ part.id }},
location_detail: true,
part_detail: false,
},
groupByField: 'location',
buttons: ['#stock-options'],
url: "{% url 'api-stock-list' %}",
});
$("#stock-export").click(function() {
exportStock({
supplier_part: {{ part.pk }},
});
});
$("#item-create").click(function() {
createNewStockItem({
data: {
part: {{ part.part.id }},
supplier_part: {{ part.id }},
},
});
});
$('#order-part, #order-part2').click(function() {
launchModalForm(
"{% url 'order-parts' %}",
{
data: {
part: {{ part.part.id }},
},
reload: true,
},
);
});
$('#edit-part').click(function () {
editSupplierPart({{ part.pk }}, {
onSuccess: function() {
location.reload();
}
});
});
$('#delete-part').click(function() {
deleteSupplierPart({{ part.pk }}, {
onSuccess: function() {
window.location.href = "{% url 'company-detail' part.supplier.id %}";
}
});
});
enableSidebar('supplierpart');
{% endblock %}