From f9f8527ae5c7cbd8209828ed80c760b703c7735f Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 6 Oct 2021 16:20:15 +1100 Subject: [PATCH] Fix build button - Now links into the API forms --- InvenTree/templates/js/translated/build.js | 14 +++++++++++++- InvenTree/templates/js/translated/order.js | 18 +++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index aa68b26dd4..7b4d3c035a 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -42,6 +42,9 @@ function buildFormFields() { part_detail: true, } }, + sales_order: { + hidden: true, + }, batch: {}, target_date: {}, take_from: {}, @@ -76,23 +79,32 @@ function newBuildOrder(options={}) { var fields = buildFormFields(); + // Specify the target part if (options.part) { fields.part.value = options.part; } + // Specify the desired quantity if (options.quantity) { fields.quantity.value = options.quantity; } + // Specify the parent build order if (options.parent) { fields.parent.value = options.parent; } + // Specify a parent sales order + if (options.sales_order) { + fields.sales_order.value = options.sales_order; + } + constructForm(`/api/build/`, { fields: fields, follow: true, method: 'POST', - title: '{% trans "Create Build Order" %}' + title: '{% trans "Create Build Order" %}', + onSuccess: options.onSuccess, }); } diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index c9a5d92b5b..69b49d5598 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -580,12 +580,14 @@ function loadPurchaseOrderTable(table, options) { return '{% trans "No purchase orders found" %}'; }, columns: [ + /* { title: '', visible: true, checkbox: true, switchable: false, }, + */ { field: 'reference', title: '{% trans "Purchase Order" %}', @@ -1576,15 +1578,13 @@ function loadSalesOrderLineItemTable(table, options={}) { if (row.allocated < row.quantity) { quantity = row.quantity - row.allocated; } - - // TODO: Migrate this to the API forms - launchModalForm(`/build/new/`, { - follow: true, - data: { - part: pk, - sales_order: options.order, - quantity: quantity, - }, + + // Create a new build order + newBuildOrder({ + part: pk, + sales_order: options.order, + quantity: quantity, + success: reloadTable }); });