mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	Filter purchaseorder API by supplier part
This commit is contained in:
		@@ -10,10 +10,22 @@
 | 
			
		||||
 | 
			
		||||
<h4>{% trans "Supplier Part Orders" %}</h4>
 | 
			
		||||
 | 
			
		||||
{% include "order/po_table.html" with orders=part.purchase_orders %}
 | 
			
		||||
<div id='button-bar'>
 | 
			
		||||
        <div class='btn-group'>
 | 
			
		||||
            <button class='btn btn-primary' type='button' id='part-order2' title='Order part'>Order Part</button>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    
 | 
			
		||||
    <table class='table table-striped table-condensed po-table' id='purchase-order-table' data-toolbar='#button-bar'>
 | 
			
		||||
    </table>
 | 
			
		||||
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block js_ready %}
 | 
			
		||||
{{ block.super }}
 | 
			
		||||
 | 
			
		||||
loadPurchaseOrderTable($("#purchase-order-table"), {
 | 
			
		||||
    url: "{% url 'api-po-list' %}?supplier_part={{ part.id }}",
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@@ -18,6 +18,7 @@ from InvenTree.status_codes import OrderStatus
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
from part.models import Part
 | 
			
		||||
from company.models import SupplierPart
 | 
			
		||||
 | 
			
		||||
from .models import PurchaseOrder, PurchaseOrderLineItem
 | 
			
		||||
from .serializers import POSerializer, POLineItemSerializer
 | 
			
		||||
@@ -62,6 +63,14 @@ class POList(generics.ListCreateAPIView):
 | 
			
		||||
            except (Part.DoesNotExist, ValueError):
 | 
			
		||||
                pass
 | 
			
		||||
 | 
			
		||||
        # Attempt to filter by supplier part
 | 
			
		||||
        if 'supplier_part' in request.GET:
 | 
			
		||||
            try:
 | 
			
		||||
                supplier_part = SupplierPart.objects.get(pk=request.GET['supplier_part'])
 | 
			
		||||
                queryset = queryset.filter(id__in=[p.id for p in supplier_part.purchase_orders()])
 | 
			
		||||
            except (ValueError, SupplierPart.DoesNotExist):
 | 
			
		||||
                pass
 | 
			
		||||
 | 
			
		||||
        data = queryset.values(
 | 
			
		||||
            'pk',
 | 
			
		||||
            'supplier',
 | 
			
		||||
 
 | 
			
		||||
@@ -3,9 +3,7 @@
 | 
			
		||||
<div id='button-toolbar'>
 | 
			
		||||
    <div class='button-toolbar container-fluid' style='float: right;'>
 | 
			
		||||
        <button class='btn btn-default' id='stock-export' title='Export Stock Information'>{% trans "Export" %}</button>
 | 
			
		||||
        {% if 1 or not part or part.is_template == False %}
 | 
			
		||||
        <button class="btn btn-success" id='item-create'>{% trans "New Stock Item" %}</button>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
        <div class="dropdown" style='float: right;'>
 | 
			
		||||
            <button id='stock-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}<span class="caret"></span></button>
 | 
			
		||||
            <ul class="dropdown-menu">
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user