mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactor PurchaseOrderEdit form
This commit is contained in:
parent
5e9372f2d6
commit
7e5c9aa043
@ -164,11 +164,30 @@ $('#print-order-report').click(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#edit-order").click(function() {
|
$("#edit-order").click(function() {
|
||||||
launchModalForm("{% url 'po-edit' order.id %}",
|
|
||||||
{
|
constructForm('{% url "api-po-detail" order.pk %}', {
|
||||||
|
fields: {
|
||||||
|
reference: {
|
||||||
|
prefix: "{% settings_value 'PURCHASEORDER_REFERENCE_PREFIX' %}",
|
||||||
|
},
|
||||||
|
{% if order.lines.count == 0 and order.status == PurchaseOrderStatus.PENDING %}
|
||||||
|
supplier: {
|
||||||
|
},
|
||||||
|
{% endif %}
|
||||||
|
description: {},
|
||||||
|
target_date: {
|
||||||
|
icon: 'fa-calendar-alt',
|
||||||
|
},
|
||||||
|
link: {
|
||||||
|
icon: 'fa-link',
|
||||||
|
},
|
||||||
|
responsible: {
|
||||||
|
icon: 'fa-user',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
title: '{% trans "Edit Purchase Order" %}',
|
||||||
reload: true,
|
reload: true,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#receive-order").click(function() {
|
$("#receive-order").click(function() {
|
||||||
|
@ -168,12 +168,6 @@ class POTests(OrderViewTestCase):
|
|||||||
response = self.client.get(url, {'supplier': 'goat'}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
response = self.client.get(url, {'supplier': 'goat'}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_po_edit(self):
|
|
||||||
""" Launch form to edit a PurchaseOrder """
|
|
||||||
|
|
||||||
response = self.client.get(reverse('po-edit', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
def test_po_export(self):
|
def test_po_export(self):
|
||||||
""" Export PurchaseOrder """
|
""" Export PurchaseOrder """
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ from . import views
|
|||||||
purchase_order_detail_urls = [
|
purchase_order_detail_urls = [
|
||||||
|
|
||||||
url(r'^cancel/', views.PurchaseOrderCancel.as_view(), name='po-cancel'),
|
url(r'^cancel/', views.PurchaseOrderCancel.as_view(), name='po-cancel'),
|
||||||
url(r'^edit/', views.PurchaseOrderEdit.as_view(), name='po-edit'),
|
|
||||||
url(r'^issue/', views.PurchaseOrderIssue.as_view(), name='po-issue'),
|
url(r'^issue/', views.PurchaseOrderIssue.as_view(), name='po-issue'),
|
||||||
url(r'^receive/', views.PurchaseOrderReceive.as_view(), name='po-receive'),
|
url(r'^receive/', views.PurchaseOrderReceive.as_view(), name='po-receive'),
|
||||||
url(r'^complete/', views.PurchaseOrderComplete.as_view(), name='po-complete'),
|
url(r'^complete/', views.PurchaseOrderComplete.as_view(), name='po-complete'),
|
||||||
|
@ -215,26 +215,6 @@ class SalesOrderCreate(AjaxCreateView):
|
|||||||
return super().save(form)
|
return super().save(form)
|
||||||
|
|
||||||
|
|
||||||
class PurchaseOrderEdit(AjaxUpdateView):
|
|
||||||
""" View for editing a PurchaseOrder using a modal form """
|
|
||||||
|
|
||||||
model = PurchaseOrder
|
|
||||||
ajax_form_title = _('Edit Purchase Order')
|
|
||||||
form_class = order_forms.EditPurchaseOrderForm
|
|
||||||
|
|
||||||
def get_form(self):
|
|
||||||
|
|
||||||
form = super(AjaxUpdateView, self).get_form()
|
|
||||||
|
|
||||||
order = self.get_object()
|
|
||||||
|
|
||||||
# Prevent user from editing supplier if there are already lines in the order
|
|
||||||
if order.lines.count() > 0 or not order.status == PurchaseOrderStatus.PENDING:
|
|
||||||
form.fields['supplier'].widget = HiddenInput()
|
|
||||||
|
|
||||||
return form
|
|
||||||
|
|
||||||
|
|
||||||
class SalesOrderEdit(AjaxUpdateView):
|
class SalesOrderEdit(AjaxUpdateView):
|
||||||
""" View for editing a SalesOrder """
|
""" View for editing a SalesOrder """
|
||||||
|
|
||||||
|
@ -383,6 +383,10 @@ function constructFormBody(fields, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fields[field].hidden = field_options.hidden;
|
fields[field].hidden = field_options.hidden;
|
||||||
|
|
||||||
|
if (field_options.read_only != null) {
|
||||||
|
fields[field].read_only = field_options.read_only;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -982,7 +986,6 @@ function initializeRelatedField(name, field, options) {
|
|||||||
|
|
||||||
select.select2({
|
select.select2({
|
||||||
placeholder: '',
|
placeholder: '',
|
||||||
allowClear: !field.required,
|
|
||||||
dropdownParent: $(options.modal),
|
dropdownParent: $(options.modal),
|
||||||
dropdownAutoWidth: false,
|
dropdownAutoWidth: false,
|
||||||
ajax: {
|
ajax: {
|
||||||
@ -1201,6 +1204,8 @@ function renderModelData(name, model, data, parameters, options) {
|
|||||||
case 'supplierpart':
|
case 'supplierpart':
|
||||||
renderer = renderSupplierPart;
|
renderer = renderSupplierPart;
|
||||||
break;
|
break;
|
||||||
|
case 'owner':
|
||||||
|
renderer = renderOwner;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,27 @@ function renderPart(name, data, parameters, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Renderer for "Owner" model
|
||||||
|
function renderOwner(name, data, parameters, options) {
|
||||||
|
|
||||||
|
var html = `<span>${data.name}</span>`;
|
||||||
|
|
||||||
|
|
||||||
|
switch (data.label) {
|
||||||
|
case 'user':
|
||||||
|
html += `<span class='float-right fas fa-user'></span>`;
|
||||||
|
break;
|
||||||
|
case 'group':
|
||||||
|
html += `<span class='float-right fas fa-users'></span>`;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Renderer for "PartCategory" model
|
// Renderer for "PartCategory" model
|
||||||
function renderPartCategory(name, data, parameters, options) {
|
function renderPartCategory(name, data, parameters, options) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user