mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Migrate views to use the API forms architecture:
- SalesOrderAllocationEdit - SalesOrderAllocationDelete
This commit is contained in:
parent
b8b4c60c43
commit
4d13674452
@ -1,14 +0,0 @@
|
|||||||
{% extends "modal_delete_form.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% load inventree_extras %}
|
|
||||||
|
|
||||||
{% block pre_form_content %}
|
|
||||||
<div class='alert alert-block alert-warning'>
|
|
||||||
{% trans "This action will unallocate the following stock from the Sales Order" %}:
|
|
||||||
<br>
|
|
||||||
<strong>
|
|
||||||
{% decimal allocation.get_allocated %} x {{ allocation.line.part.full_name }}
|
|
||||||
{% if allocation.item.location %} ({{ allocation.get_location }}){% endif %}
|
|
||||||
</strong>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -45,10 +45,6 @@ sales_order_urls = [
|
|||||||
url(r'^allocation/', include([
|
url(r'^allocation/', include([
|
||||||
url(r'^new/', views.SalesOrderAllocationCreate.as_view(), name='so-allocation-create'),
|
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'^assign-serials/', views.SalesOrderAssignSerials.as_view(), name='so-assign-serials'),
|
||||||
url(r'(?P<pk>\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
|
# Display detail view for a single SalesOrder
|
||||||
|
@ -1051,30 +1051,6 @@ class SalesOrderAllocationCreate(AjaxCreateView):
|
|||||||
return form
|
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):
|
class LineItemPricing(PartPricing):
|
||||||
""" View for inspecting part pricing information """
|
""" View for inspecting part pricing information """
|
||||||
|
|
||||||
|
@ -532,6 +532,7 @@ function editPurchaseOrderLineItem(e) {
|
|||||||
|
|
||||||
var url = $(src).attr('url');
|
var url = $(src).attr('url');
|
||||||
|
|
||||||
|
// TODO: Migrate this to the API forms
|
||||||
launchModalForm(url, {
|
launchModalForm(url, {
|
||||||
reload: true,
|
reload: true,
|
||||||
});
|
});
|
||||||
@ -547,7 +548,8 @@ function removePurchaseOrderLineItem(e) {
|
|||||||
var src = e.target || e.srcElement;
|
var src = e.target || e.srcElement;
|
||||||
|
|
||||||
var url = $(src).attr('url');
|
var url = $(src).attr('url');
|
||||||
|
|
||||||
|
// TODO: Migrate this to the API forms
|
||||||
launchModalForm(url, {
|
launchModalForm(url, {
|
||||||
reload: true,
|
reload: true,
|
||||||
});
|
});
|
||||||
@ -1162,20 +1164,38 @@ function showAllocationSubTable(index, row, element, options) {
|
|||||||
|
|
||||||
var pk = $(this).attr('pk');
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
// TODO: Migrate to API forms
|
// Edit the sales order alloction
|
||||||
launchModalForm(`/order/sales-order/allocation/${pk}/edit/`, {
|
constructForm(
|
||||||
success: reloadTable,
|
`/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
|
// Add callbacks for 'delete' buttons
|
||||||
table.find('.button-allocation-delete').click(function() {
|
table.find('.button-allocation-delete').click(function() {
|
||||||
var pk = $(this).attr('pk');
|
var pk = $(this).attr('pk');
|
||||||
|
|
||||||
// TODO: Migrate to API forms
|
constructForm(
|
||||||
launchModalForm(`/order/sales-order/allocation/${pk}/delete/`, {
|
`/api/order/so-allocation/${pk}/`,
|
||||||
success: reloadTable,
|
{
|
||||||
});
|
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={}) {
|
function loadSalesOrderLineItemTable(table, options={}) {
|
||||||
|
|
||||||
|
options.table = table;
|
||||||
|
|
||||||
options.params = options.params || {};
|
options.params = options.params || {};
|
||||||
|
|
||||||
if (!options.order) {
|
if (!options.order) {
|
||||||
|
Loading…
Reference in New Issue
Block a user