From a803f21e0cea3a39c9b07a7028b35939e4314aee Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 22 Apr 2020 23:34:27 +1000 Subject: [PATCH] Add buttons to create new builds or orders for sales order parts - Need to pre-fill the forms a bit better --- .../templates/order/sales_order_detail.html | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index 272a99af4e..24c1c93929 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -45,6 +45,7 @@ $("#so-lines-table").inventreeTable({ allocations: true, }, url: "{% url 'api-so-line-list' %}", + detailViewByClick: true, detailView: true, detailFilter: function(index, row) { return row.allocated > 0; @@ -174,11 +175,11 @@ $("#so-lines-table").inventreeTable({ var part = row.part_detail; if (part.purchaseable) { - html += makeIconButton('fa-shopping-cart', 'button-buy', pk, '{% trans "Buy parts" %}'); + html += makeIconButton('fa-shopping-cart', 'button-buy', row.part, '{% trans "Buy parts" %}'); } if (part.assembly) { - html += makeIconButton('fa-tools', 'button-build', pk, '{% trans "Build parts" %}'); + html += makeIconButton('fa-tools', 'button-build', row.part, '{% trans "Build parts" %}'); } html += makeIconButton('fa-plus', 'button-add', pk, '{% trans "Allocate parts" %}'); @@ -235,9 +236,24 @@ $("#so-lines-table").on('load-success.bs.table', function() { }); table.find(".button-build").click(function() { + var pk = $(this).attr('pk'); + + launchModalForm(`/build/new/`, { + follow: true, + data: { + part: pk, + }, + }); }); table.find(".button-buy").click(function() { + var pk = $(this).attr('pk'); + + launchModalForm("{% url 'order-parts' %}", { + data: { + parts: [pk], + }, + }); }); });