mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Merge pull request #884 from SchrodingersGat/fix-filters
Adds table filters for stock assigned to a particular customer
This commit is contained in:
		@@ -9,6 +9,12 @@
 | 
				
			|||||||
<h4>{% trans "Assigned Stock" %}</h4>
 | 
					<h4>{% trans "Assigned Stock" %}</h4>
 | 
				
			||||||
<hr>
 | 
					<hr>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div id='button-toolbar'>
 | 
				
			||||||
 | 
					    <div class='filter-list' id='filter-list-stock'>
 | 
				
			||||||
 | 
					        <!-- An empty div in which the filter list will be constructed -->
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<table class='table table-striped table-condensed' id='stock-table'></table>
 | 
					<table class='table table-striped table-condensed' id='stock-table'></table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
@@ -18,12 +24,12 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
loadStockTable($("#stock-table"), {
 | 
					loadStockTable($("#stock-table"), {
 | 
				
			||||||
    params: {
 | 
					    params: {
 | 
				
			||||||
        test: 7,
 | 
					 | 
				
			||||||
        customer: {{ company.id }},
 | 
					        customer: {{ company.id }},
 | 
				
			||||||
        part_detail: true,
 | 
					        part_detail: true,
 | 
				
			||||||
        location_detail: true,
 | 
					        location_detail: true,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    url: "{% url 'api-stock-list' %}",
 | 
					    url: "{% url 'api-stock-list' %}",
 | 
				
			||||||
 | 
					    filterKey: "customerstock",
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
@@ -235,8 +235,10 @@ function loadStockTable(table, options) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    var filters = {};
 | 
					    var filters = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    var filterKey = options.filterKey || "stock";
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
    if (!options.disableFilters) {
 | 
					    if (!options.disableFilters) {
 | 
				
			||||||
        filters = loadTableFilters("stock");
 | 
					        filters = loadTableFilters(filterKey);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var original = {};
 | 
					    var original = {};
 | 
				
			||||||
@@ -245,7 +247,7 @@ function loadStockTable(table, options) {
 | 
				
			|||||||
        original[key] = params[key];
 | 
					        original[key] = params[key];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    setupFilterList("stock", table, filterListElement);
 | 
					    setupFilterList(filterKey, table, filterListElement);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Override the default values, or add new ones
 | 
					    // Override the default values, or add new ones
 | 
				
			||||||
    for (var key in params) {
 | 
					    for (var key in params) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,24 @@ function getAvailableTableFilters(tableKey) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    tableKey = tableKey.toLowerCase();
 | 
					    tableKey = tableKey.toLowerCase();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Filters for the "customer stock" table (really a subset of "stock")
 | 
				
			||||||
 | 
					    if (tableKey == "customerstock") {
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            serialized: {
 | 
				
			||||||
 | 
					                type: 'bool',
 | 
				
			||||||
 | 
					                title: '{% trans "Is Serialized" %}',
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            serial_gte: {
 | 
				
			||||||
 | 
					                title: "{% trans "Serial number GTE" %}",
 | 
				
			||||||
 | 
					                description: "{% trans "Serial number greater than or equal to" %}"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            serial_lte: {
 | 
				
			||||||
 | 
					                title: "{% trans "Serial number LTE" %}",
 | 
				
			||||||
 | 
					                description: "{% trans "Serial number less than or equal to" %}",
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Filters for the "Stock" table
 | 
					    // Filters for the "Stock" table
 | 
				
			||||||
    if (tableKey == 'stock') {
 | 
					    if (tableKey == 'stock') {
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
@@ -39,6 +57,10 @@ function getAvailableTableFilters(tableKey) {
 | 
				
			|||||||
                title: '{% trans "Is allocated" %}',
 | 
					                title: '{% trans "Is allocated" %}',
 | 
				
			||||||
                description: '{% trans "Item has been alloacted" %}',
 | 
					                description: '{% trans "Item has been alloacted" %}',
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
 | 
					            serialized: {
 | 
				
			||||||
 | 
					                type: 'bool',
 | 
				
			||||||
 | 
					                title: '{% trans "Is Serialized" %}',
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
            serial_gte: {
 | 
					            serial_gte: {
 | 
				
			||||||
                title: "{% trans "Serial number GTE" %}",
 | 
					                title: "{% trans "Serial number GTE" %}",
 | 
				
			||||||
                description: "{% trans "Serial number greater than or equal to" %}"
 | 
					                description: "{% trans "Serial number greater than or equal to" %}"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user