From e3231bbedb780ff4a2be86662ec2fbce935701be Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 24 Nov 2020 20:58:18 +1100 Subject: [PATCH 1/3] Hide "pricing" information in the BOM table --- InvenTree/part/serializers.py | 4 ++-- InvenTree/templates/js/bom.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 7bec904ce0..0eebe6617d 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -336,7 +336,7 @@ class PartStarSerializer(InvenTreeModelSerializer): class BomItemSerializer(InvenTreeModelSerializer): """ Serializer for BomItem object """ - price_range = serializers.CharField(read_only=True) + # price_range = serializers.CharField(read_only=True) quantity = serializers.FloatField() @@ -387,7 +387,7 @@ class BomItemSerializer(InvenTreeModelSerializer): 'sub_part_detail', 'quantity', 'reference', - 'price_range', + # 'price_range', 'optional', 'overage', 'note', diff --git a/InvenTree/templates/js/bom.js b/InvenTree/templates/js/bom.js index c55429faba..9bbf8127e8 100644 --- a/InvenTree/templates/js/bom.js +++ b/InvenTree/templates/js/bom.js @@ -228,6 +228,12 @@ function loadBomTable(table, options) { } }); + /* + + // TODO - Re-introduce the pricing column at a later stage, + // once the pricing has been "fixed" + // O.W. 2020-11-24 + cols.push( { field: 'price_range', @@ -241,6 +247,7 @@ function loadBomTable(table, options) { } } }); + */ } // Part notes From 28333c1a217c71aa02eac9e92bc37e8a9ffaa370 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 24 Nov 2020 21:18:00 +1100 Subject: [PATCH 2/3] Add a simple "shell" task --- tasks.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tasks.py b/tasks.py index 30641c7c81..69c53b83d4 100644 --- a/tasks.py +++ b/tasks.py @@ -102,6 +102,16 @@ def install(c): print("Config file 'config.yaml' does not exist - copying from template.") copyfile(CONFIG_TEMPLATE_FILE, CONFIG_FILE) + +@task +def shell(c): + """ + Open a python shell with access to the InvenTree database models. + """ + + manage(c, 'shell', pty=True) + + @task def superuser(c): """ From 083d7671d0ab5e7f0b8343d8220666dcaa4caa2f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 24 Nov 2020 21:19:19 +1100 Subject: [PATCH 3/3] Bug fix for BOM table If the BOM for part included a BomItem with the same PK as the top-level part, the bootstrap-tree-grid library borked Probably for good reason, too! So we now ensure that the top-level key is unique --- InvenTree/templates/js/bom.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/InvenTree/templates/js/bom.js b/InvenTree/templates/js/bom.js index 9bbf8127e8..299045cfa5 100644 --- a/InvenTree/templates/js/bom.js +++ b/InvenTree/templates/js/bom.js @@ -140,6 +140,12 @@ function loadBomTable(table, options) { }); } + // Set the parent ID of the multi-level table. + // We prepend this with the literal string value 'top-level-', + // because otherwise the unfortunate situation where BomItem.pk == BomItem.part.pk + // AND THIS BREAKS EVERYTHING + var parent_id = `top-level-${options.parent_id}`; + // Part column cols.push( { @@ -197,11 +203,11 @@ function loadBomTable(table, options) { text = parseFloat(text); if (row.optional) { - text += " ({% trans "Optional" %})"; + text += ' ({% trans "Optional" %})'; } if (row.overage) { - text += " (+" + row.overage + ") "; + text += ` (${row.overage}) `; } return text; @@ -233,7 +239,7 @@ function loadBomTable(table, options) { // TODO - Re-introduce the pricing column at a later stage, // once the pricing has been "fixed" // O.W. 2020-11-24 - + cols.push( { field: 'price_range', @@ -334,9 +340,8 @@ function loadBomTable(table, options) { table.inventreeTable({ treeEnable: !options.editable, - rootParentId: options.parent_id, + rootParentId: parent_id, idField: 'pk', - //uniqueId: 'pk', parentIdField: 'parentId', treeShowField: 'sub_part', showColumns: true, @@ -345,12 +350,18 @@ function loadBomTable(table, options) { search: true, rowStyle: function(row, index) { if (row.validated) { - return {classes: 'rowvalid'}; + return { + classes: 'rowvalid' + }; } else { - return {classes: 'rowinvalid'}; + return { + classes: 'rowinvalid' + }; } }, - formatNoMatches: function() { return '{% trans "No BOM items found" %}'; }, + formatNoMatches: function() { + return '{% trans "No BOM items found" %}'; + }, clickToSelect: true, queryParams: filters, original: params, @@ -383,7 +394,7 @@ function loadBomTable(table, options) { } // Set the parent ID of the top-level rows - row.parentId = options.parent_id; + row.parentId = parent_id; table.bootstrapTable('updateRow', idx, row, true);