diff --git a/InvenTree/order/migrations/0015_auto_20200201_2346.py b/InvenTree/order/migrations/0015_auto_20200201_2346.py
new file mode 100644
index 0000000000..3407420fc4
--- /dev/null
+++ b/InvenTree/order/migrations/0015_auto_20200201_2346.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.2.9 on 2020-02-01 23:46
+
+from django.db import migrations
+import markdownx.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('order', '0014_auto_20191118_2328'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='purchaseorder',
+ name='notes',
+ field=markdownx.models.MarkdownxField(blank=True, help_text='Order notes'),
+ ),
+ ]
diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py
index c0be887fe1..b5538c6040 100644
--- a/InvenTree/order/models.py
+++ b/InvenTree/order/models.py
@@ -12,6 +12,8 @@ from django.contrib.auth.models import User
from django.urls import reverse
from django.utils.translation import ugettext as _
+from markdownx.models import MarkdownxField
+
from datetime import datetime
from stock.models import StockItem
@@ -81,7 +83,7 @@ class Order(models.Model):
complete_date = models.DateField(blank=True, null=True)
- notes = models.TextField(blank=True, help_text=_('Order notes'))
+ notes = MarkdownxField(blank=True, help_text=_('Order notes'))
def place_order(self):
""" Marks the order as PLACED. Order must be currently PENDING. """
diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html
new file mode 100644
index 0000000000..2cefeb6465
--- /dev/null
+++ b/InvenTree/order/templates/order/order_base.html
@@ -0,0 +1,132 @@
+{% extends "base.html" %}
+
+{% load i18n %}
+{% load static %}
+{% load inventree_extras %}
+
+{% block page_title %}
+InvenTree | {{ order }}
+{% endblock %}
+
+{% block content %}
+
+
+
+
+
{% trans "Purchase Order Details" %}
+
+
+ {% trans "Supplier" %} |
+ {{ order.supplier }} |
+
+
+ {% trans "Status" %} |
+ {% include "order/order_status.html" %} |
+
+
+ {% trans "Created" %} |
+ {{ order.creation_date }}{{ order.created_by }} |
+
+ {% if order.issue_date %}
+
+ {% trans "Issued" %} |
+ {{ order.issue_date }} |
+
+ {% endif %}
+ {% if order.status == OrderStatus.COMPLETE %}
+
+ {% trans "Received" %} |
+ {{ order.complete_date }}{{ order.received_by }} |
+
+ {% endif %}
+
+
+
+
+
+
+{% block details %}
+
+
+
+{% endblock %}
+
+
+{% endblock %}
+
+{% block js_ready %}
+{{ block.super }}
+
+{% if order.status == OrderStatus.PENDING and order.lines.count > 0 %}
+$("#place-order").click(function() {
+ launchModalForm("{% url 'purchase-order-issue' order.id %}",
+ {
+ reload: true,
+ });
+});
+{% endif %}
+
+$("#edit-order").click(function() {
+ launchModalForm("{% url 'purchase-order-edit' order.id %}",
+ {
+ reload: true,
+ }
+ );
+});
+
+$("#cancel-order").click(function() {
+ launchModalForm("{% url 'purchase-order-cancel' order.id %}", {
+ reload: true,
+ });
+});
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/order/templates/order/order_notes.html b/InvenTree/order/templates/order/order_notes.html
new file mode 100644
index 0000000000..9077108510
--- /dev/null
+++ b/InvenTree/order/templates/order/order_notes.html
@@ -0,0 +1,57 @@
+{% extends "order/order_base.html" %}
+
+{% load inventree_extras %}
+{% load i18n %}
+{% load static %}
+{% load markdownify %}
+
+{% block details %}
+
+{% include 'order/tabs.html' with tab='notes' %}
+
+{% if editing %}
+{% trans "Order Notes" %}
+
+
+
+
+{{ 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 'purchase-order-notes' order.id %}?edit=1";
+});
+{% endif %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html
index d7d34103b1..15bc55a3d8 100644
--- a/InvenTree/order/templates/order/purchase_order_detail.html
+++ b/InvenTree/order/templates/order/purchase_order_detail.html
@@ -1,104 +1,22 @@
-{% extends "base.html" %}
+{% extends "order/order_base.html" %}
+{% load inventree_extras %}
{% load i18n %}
{% load static %}
-{% load inventree_extras %}
-{% block page_title %}
-InvenTree | {{ order }}
-{% endblock %}
+{% block details %}
-{% block content %}
-
-
-
-
{% trans "Purchase Order Details" %}
-
-
- {% trans "Supplier" %} |
- {{ order.supplier }} |
-
-
- {% trans "Status" %} |
- {% include "order/order_status.html" %} |
-
-
- {% trans "Created" %} |
- {{ order.creation_date }}{{ order.created_by }} |
-
- {% if order.issue_date %}
-
- {% trans "Issued" %} |
- {{ order.issue_date }} |
-
- {% endif %}
- {% if order.status == OrderStatus.COMPLETE %}
-
- {% trans "Received" %} |
- {{ order.complete_date }}{{ order.received_by }} |
-
- {% endif %}
-
-
-
+{% include 'order/tabs.html' with tab='details' %}
{% if order.status == OrderStatus.PENDING %}
-
+
{% endif %}
-Order Items
+{% trans "Order Items" %}
@@ -162,40 +80,11 @@ InvenTree | {{ order }}
-{% if order.notes %}
-
-
-
{% trans "Notes" %}
-
{{ order.notes }}
-
-{% endif %}
-
{% endblock %}
{% block js_ready %}
-{% if order.status == OrderStatus.PENDING and order.lines.count > 0 %}
-$("#place-order").click(function() {
- launchModalForm("{% url 'purchase-order-issue' order.id %}",
- {
- reload: true,
- });
-});
-{% endif %}
-
-$("#edit-order").click(function() {
- launchModalForm("{% url 'purchase-order-edit' order.id %}",
- {
- reload: true,
- }
- );
-});
-
-$("#cancel-order").click(function() {
- launchModalForm("{% url 'purchase-order-cancel' order.id %}", {
- reload: true,
- });
-});
+{{ block.super }}
$("#po-lines-table").on('click', ".line-receive", function() {
diff --git a/InvenTree/order/templates/order/tabs.html b/InvenTree/order/templates/order/tabs.html
new file mode 100644
index 0000000000..e3bcd6a0f7
--- /dev/null
+++ b/InvenTree/order/templates/order/tabs.html
@@ -0,0 +1,10 @@
+{% load i18n %}
+
+
diff --git a/InvenTree/order/urls.py b/InvenTree/order/urls.py
index d30879cf8e..d1d7d7f5f7 100644
--- a/InvenTree/order/urls.py
+++ b/InvenTree/order/urls.py
@@ -19,6 +19,8 @@ purchase_order_detail_urls = [
url(r'^export/?', views.PurchaseOrderExport.as_view(), name='purchase-order-export'),
+ url(r'^notes/', views.PurchaseOrderNotes.as_view(), name='purchase-order-notes'),
+
url(r'^.*$', views.PurchaseOrderDetail.as_view(), name='purchase-order-detail'),
]
diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py
index 7b445fbea3..bb1702c8a2 100644
--- a/InvenTree/order/views.py
+++ b/InvenTree/order/views.py
@@ -7,8 +7,9 @@ from __future__ import unicode_literals
from django.db import transaction
from django.shortcuts import get_object_or_404
+from django.urls import reverse
from django.utils.translation import ugettext as _
-from django.views.generic import DetailView, ListView
+from django.views.generic import DetailView, ListView, UpdateView
from django.forms import HiddenInput
import logging
@@ -69,6 +70,28 @@ class PurchaseOrderDetail(DetailView):
return ctx
+class PurchaseOrderNotes(UpdateView):
+ """ View for updating the 'notes' field of a PurchaseOrder """
+
+ context_object_name = 'order'
+ template_name = 'order/order_notes.html'
+ model = PurchaseOrder
+
+ fields = ['notes']
+
+ def get_success_url(self):
+
+ return reverse('purchase-order-notes', kwargs={'pk': self.get_object().id})
+
+ def get_context_data(self, **kwargs):
+
+ ctx = super().get_context_data(**kwargs)
+
+ ctx['editing'] = str2bool(self.request.GET.get('edit', ''))
+
+ return ctx
+
+
class PurchaseOrderCreate(AjaxCreateView):
""" View for creating a new PurchaseOrder object using a modal form """