2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Refactor PurchaseOrderIssue form

This commit is contained in:
Oliver Walters
2022-05-04 15:45:13 +10:00
parent 5afc3bfce2
commit bf48e3204b
8 changed files with 84 additions and 66 deletions

View File

@ -27,6 +27,7 @@
createSalesOrderShipment,
editPurchaseOrderLineItem,
exportOrder,
issurPurchaseOrder,
loadPurchaseOrderLineItemTable,
loadPurchaseOrderExtraLineTable
loadPurchaseOrderTable,
@ -142,7 +143,9 @@ function completeShipment(shipment_id) {
});
}
/*
* Launches a modal form to mark a PurchaseOrder as "complete"
*/
function completePurchaseOrder(order_id, options={}) {
constructForm(
@ -174,39 +177,75 @@ function completePurchaseOrder(order_id, options={}) {
return html;
},
onSuccess: function(response) {
if (options.onSuccess) {
options.onSuccess(response);
}
handleFormSuccess(response, options);
}
}
);
}
/*
* Launches a modal form to mark a PurchaseOrder as 'cancelled'
*/
function cancelPurchaseOrder(order_id, options={}) {
var html = `
<div class='alert alert-info alert-block'>
{% trans "Are you sure you wish to cancel this purchase order?" %}
</div>`;
constructForm(
`/api/order/po/${order_id}/cancel/`,
{
method: 'POST',
title: '{% trans "Cancel Purchase Order" %}',
confirm: true,
preFormContent: html,
onSuccess: function(response) {
if (options.onSuccess) {
options.onSuccess(response);
preFormContent: function(opts) {
var html = `
<div class='alert alert-info alert-block'>
{% trans "Are you sure you wish to cancel this purchase order?" %}
</div>`;
if (!opts.context.can_cancel) {
html += `
<div class='alert alert-danger alert-block'>
{% trans "This purchase order can not be cancelled" %}
</div>`;
}
return html;
},
onSuccess: function(response) {
handleFormSuccess(response, options);
}
}
);
}
/*
* Launches a modal form to mark a PurchaseOrder as "issued"
*/
function issuePurchaseOrder(order_id, options={}) {
constructForm(
`/api/order/po/${order_id}/issue/`,
{
method: 'POST',
title: '{% trans "Issue Purchase Order" %}',
confirm: true,
preFormContent: function(opts) {
var html = `
<div class='alert alert-block alert-warning'>
{% trans 'After placing this purchase order, line items will no longer be editable.' %}
</div>`;
return html;
},
onSuccess: function(response) {
handleFormSuccess(response, options);
}
}
)
}
// Open a dialog to create a new sales order shipment
function createSalesOrderShipment(options={}) {