diff --git a/InvenTree/order/templates/order/sales_order_base.html b/InvenTree/order/templates/order/sales_order_base.html index adaed2b456..3ee3198b28 100644 --- a/InvenTree/order/templates/order/sales_order_base.html +++ b/InvenTree/order/templates/order/sales_order_base.html @@ -107,4 +107,10 @@ InvenTree | {% trans "Sales Order" %} {% block js_ready %} {{ block.super }} +$("#edit-order").click(function() { + launchModalForm("{% url 'so-edit' order.id %}", { + reload: true, + }); +}); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/order/urls.py b/InvenTree/order/urls.py index 086033db23..9a836e4e0b 100644 --- a/InvenTree/order/urls.py +++ b/InvenTree/order/urls.py @@ -17,13 +17,13 @@ purchase_order_attachment_urls = [ purchase_order_detail_urls = [ - 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'^receive/?', views.PurchaseOrderReceive.as_view(), name='po-receive'), - url(r'^complete/?', views.PurchaseOrderComplete.as_view(), name='po-complete'), + 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'^receive/', views.PurchaseOrderReceive.as_view(), name='po-receive'), + 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'), @@ -63,6 +63,8 @@ purchase_order_urls = [ sales_order_detail_urls = [ + url(r'^edit/', views.SalesOrderEdit.as_view(), name='so-edit'), + url(r'^.*$', views.SalesOrderDetail.as_view(), name='so-detail'), ] diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index cdf3676136..ed4febcdc8 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -265,6 +265,24 @@ class PurchaseOrderEdit(AjaxUpdateView): 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): """ View for cancelling a purchase order """