diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index 809dd0e8fb..4a95bbb166 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -132,7 +132,7 @@ class POLineItemSerializer(InvenTreeModelSerializer): purchase_price_string = serializers.CharField(source='purchase_price', read_only=True) - destination = LocationBriefSerializer(source='get_destination', read_only=True) + destination_detail = LocationBriefSerializer(source='get_destination', read_only=True) purchase_price_currency = serializers.ChoiceField( choices=currency_code_mappings(), @@ -156,6 +156,7 @@ class POLineItemSerializer(InvenTreeModelSerializer): 'purchase_price_currency', 'purchase_price_string', 'destination', + 'destination_detail', ] diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index f1146d8b01..11396e07a7 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -170,6 +170,7 @@ $("#edit-order").click(function() { supplier: { }, {% endif %} + supplier_reference: {}, description: {}, target_date: { icon: 'fa-calendar-alt', diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index 54d0ca76be..193fd75daa 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -401,8 +401,15 @@ $("#po-table").inventreeTable({ } }, { - field: 'destination.pathstring', + field: 'destination', title: '{% trans "Destination" %}', + formatter: function(value, row) { + if (value) { + return renderLink(row.destination_detail.pathstring, `/stock/location/${value}/`); + } else { + return '-'; + } + } }, { field: 'notes', diff --git a/InvenTree/order/templates/order/sales_order_base.html b/InvenTree/order/templates/order/sales_order_base.html index 7a2c63c5a6..60099a2578 100644 --- a/InvenTree/order/templates/order/sales_order_base.html +++ b/InvenTree/order/templates/order/sales_order_base.html @@ -163,6 +163,7 @@ $("#edit-order").click(function() { customer: { }, {% endif %} + customer_reference: {}, description: {}, target_date: { icon: 'fa-calendar-alt', diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 9abee816fa..3a5fee4e3d 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -118,9 +118,17 @@ class CategoryList(generics.ListCreateAPIView): ordering_fields = [ 'name', + 'level', + 'tree_id', + 'lft', ] - ordering = 'name' + # Use hierarchical ordering by default + ordering = [ + 'tree_id', + 'lft', + 'name' + ] search_fields = [ 'name', diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 6627639bca..92dda58590 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -32,6 +32,8 @@ class CategorySerializer(InvenTreeModelSerializer): parts = serializers.IntegerField(source='item_count', read_only=True) + level = serializers.IntegerField(read_only=True) + class Meta: model = PartCategory fields = [ @@ -40,10 +42,11 @@ class CategorySerializer(InvenTreeModelSerializer): 'description', 'default_location', 'default_keywords', - 'pathstring', - 'url', + 'level', 'parent', 'parts', + 'pathstring', + 'url', ] diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 08e948607a..70ab939ff1 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -363,6 +363,15 @@ class StockLocationList(generics.ListCreateAPIView): ordering_fields = [ 'name', 'items', + 'level', + 'tree_id', + 'lft', + ] + + ordering = [ + 'tree_id', + 'lft', + 'name', ] diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 38301bdd1f..a175787c63 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -260,12 +260,15 @@ class LocationSerializer(InvenTreeModelSerializer): items = serializers.IntegerField(source='item_count', read_only=True) + level = serializers.IntegerField(read_only=True) + class Meta: model = StockLocation fields = [ 'pk', 'url', 'name', + 'level', 'description', 'parent', 'pathstring', diff --git a/InvenTree/templates/js/modals.js b/InvenTree/templates/js/modals.js index b404af364c..4bcc31fffa 100644 --- a/InvenTree/templates/js/modals.js +++ b/InvenTree/templates/js/modals.js @@ -765,6 +765,9 @@ function attachSecondaryModal(modal, options) { function attachSecondaries(modal, secondaries) { /* Attach a provided list of secondary modals */ + // 2021-07-18 - Secondary modals will be disabled for now, until they are re-implemented in the "API forms" architecture + return; + for (var i = 0; i < secondaries.length; i++) { attachSecondaryModal(modal, secondaries[i]); } diff --git a/InvenTree/templates/js/model_renderers.js b/InvenTree/templates/js/model_renderers.js index caa209dc90..ddb4897d8d 100644 --- a/InvenTree/templates/js/model_renderers.js +++ b/InvenTree/templates/js/model_renderers.js @@ -67,7 +67,9 @@ function renderStockItem(name, data, parameters, options) { // Renderer for "StockLocation" model function renderStockLocation(name, data, parameters, options) { - var html = `${data.name}`; + var level = '- '.repeat(data.level); + + var html = `${level}${data.pathstring}`; if (data.description) { html += ` - ${data.description}`; @@ -75,10 +77,6 @@ function renderStockLocation(name, data, parameters, options) { html += `{% trans "Location ID" %}: ${data.pk}`; - if (data.pathstring) { - html += `

${data.pathstring}

`; - } - return html; } @@ -154,7 +152,9 @@ function renderOwner(name, data, parameters, options) { // Renderer for "PartCategory" model function renderPartCategory(name, data, parameters, options) { - var html = `${data.name}`; + var level = '- '.repeat(data.level); + + var html = `${level}${data.pathstring}`; if (data.description) { html += ` - ${data.description}`; @@ -162,10 +162,6 @@ function renderPartCategory(name, data, parameters, options) { html += `{% trans "Category ID" %}: ${data.pk}`; - if (data.pathstring) { - html += `

${data.pathstring}

`; - } - return html; } diff --git a/InvenTree/templates/js/order.js b/InvenTree/templates/js/order.js index 5cb286e970..7091eb0577 100644 --- a/InvenTree/templates/js/order.js +++ b/InvenTree/templates/js/order.js @@ -14,6 +14,7 @@ function createSalesOrder(options={}) { customer: { value: options.customer, }, + customer_reference: {}, description: {}, target_date: { icon: 'fa-calendar-alt', @@ -44,6 +45,7 @@ function createPurchaseOrder(options={}) { supplier: { value: options.supplier, }, + supplier_reference: {}, description: {}, target_date: { icon: 'fa-calendar-alt',