Add form to edit a SalesOrder

This commit is contained in:
Oliver Walters 2020-04-20 22:20:03 +10:00
parent ce1dd88129
commit e12824df2e
3 changed files with 32 additions and 6 deletions

View File

@ -107,4 +107,10 @@ InvenTree | {% trans "Sales Order" %}
{% block js_ready %} {% block js_ready %}
{{ block.super }} {{ block.super }}
$("#edit-order").click(function() {
launchModalForm("{% url 'so-edit' order.id %}", {
reload: true,
});
});
{% endblock %} {% endblock %}

View File

@ -17,13 +17,13 @@ purchase_order_attachment_urls = [
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'^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'),
url(r'^export/?', views.PurchaseOrderExport.as_view(), name='po-export'), url(r'^export/', views.PurchaseOrderExport.as_view(), name='po-export'),
url(r'^notes/', views.PurchaseOrderNotes.as_view(), name='po-notes'), url(r'^notes/', views.PurchaseOrderNotes.as_view(), name='po-notes'),
@ -63,6 +63,8 @@ purchase_order_urls = [
sales_order_detail_urls = [ sales_order_detail_urls = [
url(r'^edit/', views.SalesOrderEdit.as_view(), name='so-edit'),
url(r'^.*$', views.SalesOrderDetail.as_view(), name='so-detail'), url(r'^.*$', views.SalesOrderDetail.as_view(), name='so-detail'),
] ]

View File

@ -265,6 +265,24 @@ class PurchaseOrderEdit(AjaxUpdateView):
return form return form
class SalesOrderEdit(AjaxUpdateView):
""" View for editing a SalesOrder """
model = SalesOrder
ajax_form_title = _('Edit Sales Order')
form_class = order_forms.EditSalesOrderForm
def get_form(self):
form = super().get_form()
order = self.get_object()
# Prevent user from editing customer
form.fields['customer'].widget = HiddenInput()
return form
class PurchaseOrderCancel(AjaxUpdateView): class PurchaseOrderCancel(AjaxUpdateView):
""" View for cancelling a purchase order """ """ View for cancelling a purchase order """