diff --git a/InvenTree/order/templates/order/sales_order_notes.html b/InvenTree/order/templates/order/sales_order_notes.html new file mode 100644 index 0000000000..671b592569 --- /dev/null +++ b/InvenTree/order/templates/order/sales_order_notes.html @@ -0,0 +1,62 @@ +{% extends "order/sales_order_base.html" %} + +{% load i18n %} +{% load static %} +{% load inventree_extras %} +{% load status_codes %} +{% load markdownify %} + +{% block page_title %} +InvenTree | {% trans "Sales Order" %} +{% endblock %} + +{% block details %} + +{% include "order/so_tabs.html" with tab='notes' %} + +{% if editing %} +

{% trans "Order Notes" %}

+
+ +
+ {% csrf_token %} + + {{ form }} +
+ +
+ +{{ form.media }} + +{% else %} +
+
+

{% trans "Order Notes" %}

+
+
+ +
+
+
+
+
+ {{ order.notes | markdownify }} +
+
+ +{% endif %} + +{% endblock %} + +{% block js_ready %} + +{{ block.super }} + +{% if editing %} +{% else %} +$("#edit-notes").click(function() { + location.href = "{% url 'so-notes' order.id %}?edit=1"; +}); +{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/so_attachments.html b/InvenTree/order/templates/order/so_attachments.html new file mode 100644 index 0000000000..5d7a66e313 --- /dev/null +++ b/InvenTree/order/templates/order/so_attachments.html @@ -0,0 +1,81 @@ +{% extends "order/sales_order_base.html" %} + +{% load inventree_extras %} +{% load i18n %} +{% load static %} + +{% block details %} + +{% include 'order/so_tabs.html' with tab='attachments' %} + +

{% trans "Sales Order Attachments" %} + +
+ +
+
+ +
+
+ + + + + + + + + + + {% for attachment in order.attachments.all %} + + + + + + {% endfor %} + +
{% trans "File" %}{% trans "Comment" %}
{{ attachment.basename }}{{ attachment.comment }} +
+ + +
+
+ +{% endblock %} + +{% block js_ready %} +{{ block.super }} + +$("#new-attachment").click(function() { + launchModalForm("{% url 'po-attachment-create' %}?order={{ order.id }}", + { + reload: true, + } + ); +}); + +$("#attachment-table").on('click', '.attachment-edit-button', function() { + var button = $(this); + + launchModalForm(button.attr('url'), { + reload: true, + }); +}); + +$("#attachment-table").on('click', '.attachment-delete-button', function() { + var button = $(this); + + launchModalForm(button.attr('url'), { + reload: true, + }); +}); + +$("#attachment-table").inventreeTable({ +}); + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/so_tabs.html b/InvenTree/order/templates/order/so_tabs.html index 2bb313b0bb..fbb931d8a2 100644 --- a/InvenTree/order/templates/order/so_tabs.html +++ b/InvenTree/order/templates/order/so_tabs.html @@ -2,16 +2,16 @@ \ No newline at end of file diff --git a/InvenTree/order/urls.py b/InvenTree/order/urls.py index 9a836e4e0b..21ab912492 100644 --- a/InvenTree/order/urls.py +++ b/InvenTree/order/urls.py @@ -65,6 +65,9 @@ sales_order_detail_urls = [ url(r'^edit/', views.SalesOrderEdit.as_view(), name='so-edit'), + url(r'^attachments/', views.SalesOrderDetail.as_view(template_name='order/so_attachments.html'), name='so-attachments'), + url(r'^notes/', views.SalesOrderNotes.as_view(), name='so-notes'), + url(r'^.*$', views.SalesOrderDetail.as_view(), name='so-detail'), ] diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index ed4febcdc8..2aafc9a677 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -181,7 +181,28 @@ class PurchaseOrderNotes(UpdateView): ctx = super().get_context_data(**kwargs) - ctx['editing'] = str2bool(self.request.GET.get('edit', '')) + ctx['editing'] = str2bool(self.request.GET.get('edit', False)) + + return ctx + + +class SalesOrderNotes(UpdateView): + """ View for editing the 'notes' field of a SalesORder """ + + context_object_name = 'order' + template_name = 'order/sales_order_notes.html' + model = SalesOrder + + fields = ['notes'] + + def get_success_url(self): + return reverse('so-notes', kwargs={'pk': self.get_object().pk}) + + def get_context_data(self, **kwargs): + + ctx = super().get_context_data(**kwargs) + + ctx['editing'] = str2bool(self.request.GET.get('edit', False)) return ctx