Fix build button

- Now links into the API forms
This commit is contained in:
Oliver 2021-10-06 16:20:15 +11:00
parent 4d2cf233b3
commit f9f8527ae5
2 changed files with 22 additions and 10 deletions

View File

@ -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,
});
}

View File

@ -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
});
});