From 457bcdc0ae26e76f168a89d562e59a492f65c4f0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 1 Mar 2022 23:38:02 +1100 Subject: [PATCH 1/7] Fix some small template / JS errors on the "part" page --- InvenTree/part/templates/part/detail.html | 17 +++++++++++++++-- InvenTree/templates/js/translated/tables.js | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 1cfd6c13e2..a6cfda757f 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -122,7 +122,13 @@

{% trans "Sales Order Allocations" %}

-
+ +
+
+ {% include "filter_list.html" with id="salesorderallocation" %} +
+
+
@@ -342,7 +348,12 @@

{% trans "Build Order Allocations" %}

-
+
+
+ {% include "filter_list.html" with id="buildorderallocation" %} +
+
+
@@ -722,6 +733,7 @@ }); // Load the BOM table data in the pricing view + {% if part.has_bom and roles.sales_order.view %} loadBomTable($("#bom-pricing-table"), { editable: false, bom_url: "{% url 'api-bom-list' %}", @@ -729,6 +741,7 @@ parent_id: {{ part.id }} , sub_part_detail: true, }); + {% endif %} onPanelLoad("purchase-orders", function() { loadPartPurchaseOrderTable( diff --git a/InvenTree/templates/js/translated/tables.js b/InvenTree/templates/js/translated/tables.js index 4c9bec0476..c2418dbe78 100644 --- a/InvenTree/templates/js/translated/tables.js +++ b/InvenTree/templates/js/translated/tables.js @@ -278,7 +278,7 @@ $.fn.inventreeTable = function(options) { } }); } else { - console.log(`Could not get list of visible columns for column '${tableName}'`); + console.log(`Could not get list of visible columns for table '${tableName}'`); } } From 28a7ad7f0e285d57531c97c2532b0aabb004690d Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 1 Mar 2022 23:53:33 +1100 Subject: [PATCH 2/7] Bug fix for BuildOrder.bom_items - Now uses the query generator provided by the Part model - No more code duplication - More importantly, no more code duplication which is WRONG! --- InvenTree/build/models.py | 4 +--- InvenTree/part/models.py | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 095a8cf70c..01c2c781e9 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -383,9 +383,7 @@ class Build(MPTTModel, ReferenceIndexingMixin): Returns the BOM items for the part referenced by this BuildOrder """ - return self.part.bom_items.all().prefetch_related( - 'sub_part' - ) + return self.part.get_bom_items() @property def tracked_bom_items(self): diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 33ad8bf612..09e1f77542 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1453,7 +1453,9 @@ class Part(MPTTModel): By default, will include inherited BOM items """ - return BomItem.objects.filter(self.get_bom_item_filter(include_inherited=include_inherited)) + queryset = BomItem.objects.filter(self.get_bom_item_filter(include_inherited=include_inherited)) + + return queryset.prefetch_related('sub_part') def get_installed_part_options(self, include_inherited=True, include_variants=True): """ From aeb9dfe37179efc173206d9178fa1e1622f00282 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 1 Mar 2022 23:58:30 +1100 Subject: [PATCH 3/7] Allows deletion of serialized stock --- InvenTree/stock/models.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 64b47da6d3..14132d297b 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -909,7 +909,6 @@ class StockItem(MPTTModel): """ Can this stock item be deleted? It can NOT be deleted under the following circumstances: - Has installed stock items - - Has a serial number and is tracked - Is installed inside another StockItem - It has been assigned to a SalesOrder - It has been assigned to a BuildOrder @@ -918,9 +917,6 @@ class StockItem(MPTTModel): if self.installed_item_count() > 0: return False - if self.part.trackable and self.serial is not None: - return False - if self.sales_order is not None: return False From f6b3760bb5d5025f5a974ef9985f31c078035261 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 2 Mar 2022 00:05:02 +1100 Subject: [PATCH 4/7] Make UI elements more consistent Ref: https://github.com/inventree/InvenTree/issues/2692 --- InvenTree/part/templates/part/part_base.html | 4 ++-- InvenTree/stock/templates/stock/item_base.html | 2 +- InvenTree/templates/stock_table.html | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 823bb1a4f3..fe18c68a38 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -59,13 +59,13 @@