Refactor order parts for manfuacturer part detail page

This commit is contained in:
Oliver Walters 2022-05-03 17:16:38 +10:00
parent 28f3244574
commit 05b01e4d6c
2 changed files with 23 additions and 10 deletions

View File

@ -31,13 +31,11 @@
{% include "admin_button.html" with url=url %} {% include "admin_button.html" with url=url %}
{% endif %} {% endif %}
{% if roles.purchase_order.change %} {% if roles.purchase_order.change %}
{% comment "for later" %} {% if roles.purchase_order.add and part.part.purchaseable %}
{% if roles.purchase_order.add %}
<button type='button' class='btn btn-outline-secondary' id='order-part' title='{% trans "Order part" %}'> <button type='button' class='btn btn-outline-secondary' id='order-part' title='{% trans "Order part" %}'>
<span class='fas fa-shopping-cart'></span> <span class='fas fa-shopping-cart'></span>
</button> </button>
{% endif %} {% endif %}
{% endcomment %}
<button type='button' class='btn btn-outline-secondary' id='edit-part' title='{% trans "Edit manufacturer part" %}'> <button type='button' class='btn btn-outline-secondary' id='edit-part' title='{% trans "Edit manufacturer part" %}'>
<span class='fas fa-edit icon-green'/> <span class='fas fa-edit icon-green'/>
</button> </button>
@ -130,6 +128,7 @@ src="{% static 'img/blank_image.png' %}"
<li><a class='dropdown-item' href='#' id='supplier-part-delete' title='{% trans "Delete supplier parts" %}'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete" %}</a></li> <li><a class='dropdown-item' href='#' id='supplier-part-delete' title='{% trans "Delete supplier parts" %}'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete" %}</a></li>
</ul> </ul>
</div> </div>
{% include "filter_list.html" with id='supplier-part' %}
</div> </div>
</div> </div>
@ -300,14 +299,20 @@ linkButtonsToSelection($("#supplier-table"), ['#supplier-part-options']);
linkButtonsToSelection($("#parameter-table"), ['#parameter-options']); linkButtonsToSelection($("#parameter-table"), ['#parameter-options']);
$('#order-part, #order-part2').click(function() { $('#order-part, #order-part2').click(function() {
launchModalForm(
"{% url 'order-parts' %}", inventreeGet(
'{% url "api-part-detail" part.part.pk %}', {},
{ {
data: { success: function(response) {
part: {{ part.part.id }},
}, orderParts([response], {
reload: true, manufacturer_part: {{ part.pk }},
}, {% if part.manufacturer %}
manufacturer: {{ part.manufacturer.pk }},
{% endif %}
});
}
}
); );
}); });

View File

@ -639,6 +639,14 @@ function orderParts(parts_list, options={}) {
supplier_part_filters.supplier = options.supplier; supplier_part_filters.supplier = options.supplier;
} }
if (options.manufacturer) {
supplier_part_filters.manufacturer = options.manufacturer;
}
if (options.manufacturer_part) {
supplier_part_filters.manufacturer_part = options.manufacturer_part;
}
// Construct API filtres for the PurchaseOrder field // Construct API filtres for the PurchaseOrder field
var order_filters = { var order_filters = {
status: {{ PurchaseOrderStatus.PENDING }}, status: {{ PurchaseOrderStatus.PENDING }},