From a63d5012f0b2c4e66d2d31e1cae21bf034fc119d Mon Sep 17 00:00:00 2001 From: eeintech Date: Wed, 28 Apr 2021 13:16:40 -0400 Subject: [PATCH] Purchase order fixes --- InvenTree/order/models.py | 8 +++--- .../order/templates/order/order_base.html | 24 +++++++++++++++++ .../order/templates/order/order_cancel.html | 4 ++- .../order/templates/order/order_complete.html | 6 ++--- .../order/templates/order/order_issue.html | 4 ++- .../order/purchase_order_detail.html | 26 ------------------- InvenTree/templates/stock_table.html | 4 ++- 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 0c22b7978b..842d1f3a49 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -337,14 +337,16 @@ class PurchaseOrder(Order): raise ValidationError({"status": _("Lines can only be received against an order marked as 'Placed'")}) try: + if not (quantity % 1 == 0): + raise ValidationError({"quantity": _("Quantity must be an integer")}) + if quantity < 0: + raise ValidationError({"quantity": _("Quantity must be a positive number")}) quantity = int(quantity) - if quantity <= 0: - raise ValidationError({"quantity": _("Quantity must be greater than zero")}) except ValueError: raise ValidationError({"quantity": _("Invalid quantity provided")}) # Create a new stock item - if line.part: + if line.part and quantity > 0: stock = stock_models.StockItem( part=line.part.part, supplier_part=line.part, diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index 5dfc30796f..b29b62a4ad 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -171,11 +171,35 @@ $("#edit-order").click(function() { ); }); +$("#receive-order").click(function() { + launchModalForm("{% url 'po-receive' order.id %}", { + reload: true, + secondary: [ + { + field: 'location', + label: '{% trans "New Location" %}', + title: '{% trans "Create new stock location" %}', + url: "{% url 'stock-location-create' %}", + }, + ] + }); +}); + +$("#complete-order").click(function() { + launchModalForm("{% url 'po-complete' order.id %}", { + reload: true, + }); +}); + $("#cancel-order").click(function() { launchModalForm("{% url 'po-cancel' order.id %}", { reload: true, }); }); +$("#export-order").click(function() { + location.href = "{% url 'po-export' order.id %}"; +}); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/order_cancel.html b/InvenTree/order/templates/order/order_cancel.html index 91707ae737..7cdb03ae20 100644 --- a/InvenTree/order/templates/order/order_cancel.html +++ b/InvenTree/order/templates/order/order_cancel.html @@ -4,6 +4,8 @@ {% block pre_form_content %} -{% trans "Cancelling this order means that the order will no longer be editable." %} +
+ {% trans "Cancelling this order means that the order and line items will no longer be editable." %} +
{% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/order_complete.html b/InvenTree/order/templates/order/order_complete.html index 5c4ece7f1a..ef35841f9d 100644 --- a/InvenTree/order/templates/order/order_complete.html +++ b/InvenTree/order/templates/order/order_complete.html @@ -6,9 +6,9 @@ {% trans 'Mark this order as complete?' %} {% if not order.is_complete %} -
- {% trans 'This order has line items which have not been marked as received.' %} - {% trans 'Marking this order as complete will remove these line items.' %} +
+ {% trans 'This order has line items which have not been marked as received.' %}
+ {% trans 'Completing this order means that the order and line items will no longer be editable.' %}
{% endif %} diff --git a/InvenTree/order/templates/order/order_issue.html b/InvenTree/order/templates/order/order_issue.html index bb3c3eea8a..058a7b529c 100644 --- a/InvenTree/order/templates/order/order_issue.html +++ b/InvenTree/order/templates/order/order_issue.html @@ -4,6 +4,8 @@ {% block pre_form_content %} -{% trans 'After placing this purchase order, line items will no longer be editable.' %} +
+ {% trans 'After placing this purchase order, line items will no longer be editable.' %} +
{% 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 93b7ffbd8e..f6231371ac 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -35,31 +35,6 @@ {{ block.super }} - -$("#receive-order").click(function() { - launchModalForm("{% url 'po-receive' order.id %}", { - reload: true, - secondary: [ - { - field: 'location', - label: '{% trans "New Location" %}', - title: '{% trans "Create new stock location" %}', - url: "{% url 'stock-location-create' %}", - }, - ] - }); -}); - -$("#complete-order").click(function() { - launchModalForm("{% url 'po-complete' order.id %}", { - reload: true, - }); -}); - -$("#export-order").click(function() { - location.href = "{% url 'po-export' order.id %}"; -}); - {% if order.status == PurchaseOrderStatus.PENDING %} $('#new-po-line').click(function() { launchModalForm("{% url 'po-line-item-create' %}", @@ -261,5 +236,4 @@ $("#po-table").inventreeTable({ ] }); - {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html index 1f54767f02..d917bac72a 100644 --- a/InvenTree/templates/stock_table.html +++ b/InvenTree/templates/stock_table.html @@ -16,7 +16,7 @@ {% if owner_control.value == "True" and user in owners or user.is_superuser or owner_control.value == "False" %} - {% if roles.stock.add %} + {% if not read_only and roles.stock.add %} @@ -44,6 +44,7 @@ {% endif %}
+ {% if not read_only %} {% if roles.stock.change or roles.stock.delete %}
{% endif %} {% endif %} + {% endif %}