mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-06 07:18:48 +00:00
Allow "pending" or "issued" sales orders to be marked as completed (#4564)
* Allow "pending" or "issued" sales orders to be marked as completed * Display pending shipments for open sales orders * Add "is_open" method for PurchasesOrder - Bring into line with SalesOrder and ReturnOrder
This commit is contained in:
parent
b0668b72b7
commit
3018087ea9
@ -479,6 +479,11 @@ class PurchaseOrder(TotalPriceMixin, Order):
|
|||||||
"""Return True if the PurchaseOrder is 'pending'"""
|
"""Return True if the PurchaseOrder is 'pending'"""
|
||||||
return self.status == PurchaseOrderStatus.PENDING
|
return self.status == PurchaseOrderStatus.PENDING
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_open(self):
|
||||||
|
"""Return True if the PurchaseOrder is 'open'"""
|
||||||
|
return self.status in PurchaseOrderStatus.OPEN
|
||||||
|
|
||||||
def can_cancel(self):
|
def can_cancel(self):
|
||||||
"""A PurchaseOrder can only be cancelled under the following circumstances.
|
"""A PurchaseOrder can only be cancelled under the following circumstances.
|
||||||
|
|
||||||
@ -813,9 +818,9 @@ class SalesOrder(TotalPriceMixin, Order):
|
|||||||
if self.lines.count() == 0:
|
if self.lines.count() == 0:
|
||||||
raise ValidationError(_('Order cannot be completed as no parts have been assigned'))
|
raise ValidationError(_('Order cannot be completed as no parts have been assigned'))
|
||||||
|
|
||||||
# Only a PENDING order can be marked as SHIPPED
|
# Only an open order can be marked as shipped
|
||||||
elif self.status != SalesOrderStatus.PENDING:
|
elif not self.is_open:
|
||||||
raise ValidationError(_('Only a pending order can be marked as complete'))
|
raise ValidationError(_('Only an open order can be marked as complete'))
|
||||||
|
|
||||||
elif self.pending_shipment_count > 0:
|
elif self.pending_shipment_count > 0:
|
||||||
raise ValidationError(_("Order cannot be completed as there are incomplete shipments"))
|
raise ValidationError(_("Order cannot be completed as there are incomplete shipments"))
|
||||||
|
@ -57,11 +57,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{% if order.status == PurchaseOrderStatus.PENDING %}
|
{% if order.is_pending %}
|
||||||
<button type='button' class='btn btn-primary' id='place-order' title='{% trans "Submit Order" %}'>
|
<button type='button' class='btn btn-primary' id='place-order' title='{% trans "Submit Order" %}'>
|
||||||
<span class='fas fa-paper-plane'></span> {% trans "Submit Order" %}
|
<span class='fas fa-paper-plane'></span> {% trans "Submit Order" %}
|
||||||
</button>
|
</button>
|
||||||
{% elif order.status == PurchaseOrderStatus.PLACED %}
|
{% elif order.is_open %}
|
||||||
<button type='button' class='btn btn-primary' id='receive-order' title='{% trans "Receive items" %}'>
|
<button type='button' class='btn btn-primary' id='receive-order' title='{% trans "Receive items" %}'>
|
||||||
<span class='fas fa-sign-in-alt'></span>
|
<span class='fas fa-sign-in-alt'></span>
|
||||||
{% trans "Receive Items" %}
|
{% trans "Receive Items" %}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
{% include "spacer.html" %}
|
{% include "spacer.html" %}
|
||||||
<div class='btn-group' role='group'>
|
<div class='btn-group' role='group'>
|
||||||
{% if roles.purchase_order.change %}
|
{% if roles.purchase_order.change %}
|
||||||
{% if order.is_pending or allow_extra_editing %}
|
{% if order.is_open or allow_extra_editing %}
|
||||||
<a class='btn btn-primary' href='{% url "po-upload" order.id %}' role='button'>
|
<a class='btn btn-primary' href='{% url "po-upload" order.id %}' role='button'>
|
||||||
<span class='fas fa-file-upload side-icon'></span> {% trans "Upload File" %}
|
<span class='fas fa-file-upload side-icon'></span> {% trans "Upload File" %}
|
||||||
</a>
|
</a>
|
||||||
@ -40,7 +40,7 @@
|
|||||||
<div class='panel-content'>
|
<div class='panel-content'>
|
||||||
<div id='order-toolbar-buttons' class='btn-group' style='float: right;'>
|
<div id='order-toolbar-buttons' class='btn-group' style='float: right;'>
|
||||||
{% if roles.purchase_order.change %}
|
{% if roles.purchase_order.change %}
|
||||||
{% if order.is_pending or allow_extra_editing %}
|
{% if order.is_open or allow_extra_editing %}
|
||||||
<div class='btn-group' role='group'>
|
<div class='btn-group' role='group'>
|
||||||
<!-- Multiple-select actions -->
|
<!-- Multiple-select actions -->
|
||||||
<button id='multi-select-options' class='btn btn-primary dropdown-toggle' data-bs-toggle='dropdown'>
|
<button id='multi-select-options' class='btn btn-primary dropdown-toggle' data-bs-toggle='dropdown'>
|
||||||
@ -68,7 +68,7 @@
|
|||||||
{% include "spacer.html" %}
|
{% include "spacer.html" %}
|
||||||
<div class='btn-group' role='group'>
|
<div class='btn-group' role='group'>
|
||||||
{% if roles.purchase_order.change %}
|
{% if roles.purchase_order.change %}
|
||||||
{% if order.is_pending or allow_extra_editing %}
|
{% if order.is_open or allow_extra_editing %}
|
||||||
<button type='button' class='btn btn-success' id='new-po-extra-line'>
|
<button type='button' class='btn btn-success' id='new-po-extra-line'>
|
||||||
<span class='fas fa-plus-circle'></span> {% trans "Add Extra Line" %}
|
<span class='fas fa-plus-circle'></span> {% trans "Add Extra Line" %}
|
||||||
</button>
|
</button>
|
||||||
@ -248,7 +248,7 @@ onPanelLoad('order-items', function() {
|
|||||||
name: 'purchaseorderextraline',
|
name: 'purchaseorderextraline',
|
||||||
filtertarget: '#filter-list-purchase-order-extra-lines',
|
filtertarget: '#filter-list-purchase-order-extra-lines',
|
||||||
{% settings_value "PURCHASEORDER_EDIT_COMPLETED_ORDERS" as allow_edit %}
|
{% settings_value "PURCHASEORDER_EDIT_COMPLETED_ORDERS" as allow_edit %}
|
||||||
{% if order.is_pending or allow_edit %}
|
{% if order.is_open or allow_edit %}
|
||||||
allow_edit: {% js_bool roles.purchase_order.change %},
|
allow_edit: {% js_bool roles.purchase_order.change %},
|
||||||
allow_delete: {% js_bool roles.purchase_order.delete %},
|
allow_delete: {% js_bool roles.purchase_order.delete %},
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if order.is_pending %}
|
{% if order.is_open %}
|
||||||
<div class='panel panel-hidden' id='panel-order-shipments'>
|
<div class='panel panel-hidden' id='panel-order-shipments'>
|
||||||
<div class='panel-heading'>
|
<div class='panel-heading'>
|
||||||
<div class='d-flex flex-row'>
|
<div class='d-flex flex-row'>
|
||||||
@ -166,7 +166,7 @@
|
|||||||
// Callback when the "shipments" panel is first loaded
|
// Callback when the "shipments" panel is first loaded
|
||||||
onPanelLoad('order-shipments', function() {
|
onPanelLoad('order-shipments', function() {
|
||||||
|
|
||||||
{% if order.is_pending %}
|
{% if order.is_open %}
|
||||||
loadSalesOrderShipmentTable('#pending-shipments-table', {
|
loadSalesOrderShipmentTable('#pending-shipments-table', {
|
||||||
order: {{ order.pk }},
|
order: {{ order.pk }},
|
||||||
shipped: false,
|
shipped: false,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{% trans "Line Items" as text %}
|
{% trans "Line Items" as text %}
|
||||||
{% include "sidebar_item.html" with label='order-items' text=text icon="fa-list-ol" %}
|
{% include "sidebar_item.html" with label='order-items' text=text icon="fa-list-ol" %}
|
||||||
{% if order.is_pending %}
|
{% if order.is_open %}
|
||||||
{% trans "Pending Shipments" as text %}
|
{% trans "Pending Shipments" as text %}
|
||||||
{% include "sidebar_item.html" with label='order-shipments' text=text icon="fa-truck-loading" %}
|
{% include "sidebar_item.html" with label='order-shipments' text=text icon="fa-truck-loading" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user