From cbdea9f18cbc0c77266e0cbf7aba3fea13167e1a Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 29 Nov 2019 20:37:34 +1100 Subject: [PATCH 1/7] Reload page after ordering parts --- InvenTree/part/templates/part/part_base.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 8b11f0ff30..70640027ce 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -230,7 +230,8 @@ launchModalForm("{% url 'order-parts' %}", { data: { part: {{ part.id }}, - } + }, + reload: true, }); }); From 3f172cb065f61e196343798f3c22b107a0902b5e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 5 Dec 2019 09:12:37 +1100 Subject: [PATCH 2/7] Add 'new location' button when receiving parts by individual line --- .../order/templates/order/purchase_order_detail.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index d0bd0e3f53..0ee447ef0e 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -202,7 +202,15 @@ $("#po-lines-table").on('click', ".line-receive", function() { reload: true, data: { line: button.attr('pk') - } + }, + secondary: [ + { + field: 'location', + label: 'New Location', + title: 'Create new stock location', + url: "{% url 'stock-location-create' %}", + }, + ] }); }); From 7f2804dff319cf4348d9951d16d3bc64bc020fb4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 5 Dec 2019 10:29:16 +1100 Subject: [PATCH 3/7] Add button to mark a purchase order as complete, even if not all line items are received --- InvenTree/order/forms.py | 11 ++++++ InvenTree/order/models.py | 6 ++++ .../order/templates/order/order_complete.html | 13 +++++++ .../order/purchase_order_detail.html | 11 ++++++ InvenTree/order/urls.py | 1 + InvenTree/order/views.py | 36 +++++++++++++++++++ 6 files changed, 78 insertions(+) create mode 100644 InvenTree/order/templates/order/order_complete.html diff --git a/InvenTree/order/forms.py b/InvenTree/order/forms.py index 8432d9a6ef..97e0f0bdd9 100644 --- a/InvenTree/order/forms.py +++ b/InvenTree/order/forms.py @@ -27,6 +27,17 @@ class IssuePurchaseOrderForm(HelperForm): ] +class CompletePurchaseOrderForm(HelperForm): + + confirm = forms.BooleanField(required=False, help_text=_("Mark order as complete")) + + class Meta: + model = PurchaseOrder + fields = [ + 'confirm', + ] + + class CancelPurchaseOrderForm(HelperForm): confirm = forms.BooleanField(required=False, help_text=_('Cancel order')) diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index b1b93b990a..c0be887fe1 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -188,6 +188,12 @@ class PurchaseOrder(Order): return self.lines.filter(quantity__gt=F('received')) + @property + def is_complete(self): + """ Return True if all line items have been received """ + + return self.pending_line_items().count() == 0 + @transaction.atomic def receive_line_item(self, line, location, quantity, user): """ Receive a line item (or partial line item) against this PO diff --git a/InvenTree/order/templates/order/order_complete.html b/InvenTree/order/templates/order/order_complete.html new file mode 100644 index 0000000000..f6b9f14338 --- /dev/null +++ b/InvenTree/order/templates/order/order_complete.html @@ -0,0 +1,13 @@ +{% extends "modal_form.html" %} + +{% block pre_form_content %} + +Mark this order as complete? +{% if not order.is_complete %} +
+ This order has line items which have not been marked as received. + Marking this order as complete will remove these line items. +
+{% 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 0ee447ef0e..d7d34103b1 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -44,6 +44,9 @@ InvenTree | {{ order }} + {% endif %} {% if order.status == OrderStatus.PENDING or order.status == OrderStatus.PLACED %}