diff --git a/InvenTree/order/templates/order/so_allocation_delete.html b/InvenTree/order/templates/order/so_allocation_delete.html
deleted file mode 100644
index 34cf20083b..0000000000
--- a/InvenTree/order/templates/order/so_allocation_delete.html
+++ /dev/null
@@ -1,14 +0,0 @@
-{% extends "modal_delete_form.html" %}
-{% load i18n %}
-{% load inventree_extras %}
-
-{% block pre_form_content %}
-
- {% trans "This action will unallocate the following stock from the Sales Order" %}:
-
-
- {% decimal allocation.get_allocated %} x {{ allocation.line.part.full_name }}
- {% if allocation.item.location %} ({{ allocation.get_location }}){% endif %}
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/order/urls.py b/InvenTree/order/urls.py
index 5ea9a56867..5cdcd3f18d 100644
--- a/InvenTree/order/urls.py
+++ b/InvenTree/order/urls.py
@@ -45,10 +45,6 @@ sales_order_urls = [
url(r'^allocation/', include([
url(r'^new/', views.SalesOrderAllocationCreate.as_view(), name='so-allocation-create'),
url(r'^assign-serials/', views.SalesOrderAssignSerials.as_view(), name='so-assign-serials'),
- url(r'(?P\d+)/', include([
- url(r'^edit/', views.SalesOrderAllocationEdit.as_view(), name='so-allocation-edit'),
- url(r'^delete/', views.SalesOrderAllocationDelete.as_view(), name='so-allocation-delete'),
- ])),
])),
# Display detail view for a single SalesOrder
diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py
index 8a5e709926..5d1a4aed76 100644
--- a/InvenTree/order/views.py
+++ b/InvenTree/order/views.py
@@ -1051,30 +1051,6 @@ class SalesOrderAllocationCreate(AjaxCreateView):
return form
-class SalesOrderAllocationEdit(AjaxUpdateView):
-
- model = SalesOrderAllocation
- form_class = order_forms.EditSalesOrderAllocationForm
- ajax_form_title = _('Edit Allocation Quantity')
-
- def get_form(self):
- form = super().get_form()
-
- # Prevent the user from editing particular fields
- form.fields.pop('item')
- form.fields.pop('line')
-
- return form
-
-
-class SalesOrderAllocationDelete(AjaxDeleteView):
-
- model = SalesOrderAllocation
- ajax_form_title = _("Remove allocation")
- context_object_name = 'allocation'
- ajax_template_name = "order/so_allocation_delete.html"
-
-
class LineItemPricing(PartPricing):
""" View for inspecting part pricing information """
diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js
index f5d9117cbf..771490b134 100644
--- a/InvenTree/templates/js/translated/order.js
+++ b/InvenTree/templates/js/translated/order.js
@@ -532,6 +532,7 @@ function editPurchaseOrderLineItem(e) {
var url = $(src).attr('url');
+ // TODO: Migrate this to the API forms
launchModalForm(url, {
reload: true,
});
@@ -547,7 +548,8 @@ function removePurchaseOrderLineItem(e) {
var src = e.target || e.srcElement;
var url = $(src).attr('url');
-
+
+ // TODO: Migrate this to the API forms
launchModalForm(url, {
reload: true,
});
@@ -1162,20 +1164,38 @@ function showAllocationSubTable(index, row, element, options) {
var pk = $(this).attr('pk');
- // TODO: Migrate to API forms
- launchModalForm(`/order/sales-order/allocation/${pk}/edit/`, {
- success: reloadTable,
- });
+ // Edit the sales order alloction
+ constructForm(
+ `/api/order/so-allocation/${pk}/`,
+ {
+ fields: {
+ quantity: {},
+ },
+ title: '{% trans "Edit Stock Allocation" %}',
+ onSuccess: function() {
+ // Refresh the parent table
+ $(options.table).bootstrapTable('refresh');
+ },
+ },
+ );
});
// Add callbacks for 'delete' buttons
table.find('.button-allocation-delete').click(function() {
var pk = $(this).attr('pk');
- // TODO: Migrate to API forms
- launchModalForm(`/order/sales-order/allocation/${pk}/delete/`, {
- success: reloadTable,
- });
+ constructForm(
+ `/api/order/so-allocation/${pk}/`,
+ {
+ method: 'DELETE',
+ confirmMessage: '{% trans "Confirm Delete Operation" %}',
+ title: '{% trans "Delete Stock Allocation" %}',
+ onSuccess: function() {
+ // Refresh the parent table
+ $(options.table).bootstrapTable('refresh');
+ }
+ }
+ );
});
}
@@ -1308,6 +1328,8 @@ function showFulfilledSubTable(index, row, element, options) {
*/
function loadSalesOrderLineItemTable(table, options={}) {
+ options.table = table;
+
options.params = options.params || {};
if (!options.order) {