{% include "InvenTree/settings/setting.html" with key="PURCHASEORDER_REFERENCE_PATTERN" %}
+ {% include "InvenTree/settings/setting.html" with key="PURCHASEORDER_EDIT_COMPLETED_ORDERS" icon='fa-edit' %}
{% endblock %}
diff --git a/InvenTree/templates/InvenTree/settings/so.html b/InvenTree/templates/InvenTree/settings/so.html
index b887f24c96..f45cccd630 100644
--- a/InvenTree/templates/InvenTree/settings/so.html
+++ b/InvenTree/templates/InvenTree/settings/so.html
@@ -13,6 +13,7 @@
{% include "InvenTree/settings/setting.html" with key="SALESORDER_REFERENCE_PATTERN" %}
{% include "InvenTree/settings/setting.html" with key="SALESORDER_DEFAULT_SHIPMENT" icon="fa-truck-loading" %}
+ {% include "InvenTree/settings/setting.html" with key="SALESORDER_EDIT_COMPLETED_ORDERS" icon='fa-edit' %}
diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js
index ebc4a918e5..1db00c9697 100644
--- a/InvenTree/templates/js/translated/order.js
+++ b/InvenTree/templates/js/translated/order.js
@@ -2084,6 +2084,11 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
options.params['order'] = options.order;
options.params['part_detail'] = true;
+ // Override 'editing' if order is not pending
+ if (!options.pending && !global_settings.PURCHASEORDER_EDIT_COMPLETED_ORDERS) {
+ options.allow_edit = false;
+ }
+
var filters = loadTableFilters('purchaseorderlineitem');
for (var key in options.params) {
@@ -2445,6 +2450,10 @@ function loadPurchaseOrderExtraLineTable(table, options={}) {
options.table = table;
+ if (!options.pending && !global_settings.PURCHASEORDER_EDIT_COMPLETED_ORDERS) {
+ options.allow_edit = false;
+ }
+
options.params = options.params || {};
if (!options.order) {
@@ -2561,9 +2570,11 @@ function loadPurchaseOrderExtraLineTable(table, options={}) {
var pk = row.pk;
- html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line" %}');
- html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line" %}');
- html += makeIconButton('fa-trash-alt icon-red', 'button-delete', pk, '{% trans "Delete line" %}', );
+ if (options.allow_edit) {
+ html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line" %}');
+ html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line" %}');
+ html += makeIconButton('fa-trash-alt icon-red', 'button-delete', pk, '{% trans "Delete line" %}', );
+ }
html += ``;
@@ -3740,6 +3751,10 @@ function loadSalesOrderLineItemTable(table, options={}) {
options.table = table;
+ if (!options.pending && !global_settings.SALESORDER_EDIT_COMPLETED_ORDERS) {
+ options.allow_edit = false;
+ }
+
options.params = options.params || {};
if (!options.order) {
@@ -3769,7 +3784,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
setupFilterList('salesorderlineitem', $(table), filter_target);
// Is the order pending?
- var pending = options.status == {{ SalesOrderStatus.PENDING }};
+ var pending = options.pending;
// Has the order shipped?
var shipped = options.status == {{ SalesOrderStatus.SHIPPED }};
@@ -4287,6 +4302,10 @@ function loadSalesOrderExtraLineTable(table, options={}) {
options.table = table;
+ if (!options.pending && !global_settings.SALESORDER_EDIT_COMPLETED_ORDERS) {
+ options.allow_edit = false;
+ }
+
options.params = options.params || {};
if (!options.order) {
@@ -4401,14 +4420,14 @@ function loadSalesOrderExtraLineTable(table, options={}) {
var html = `
`;
- var pk = row.pk;
-
- html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line" %}');
- html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line" %}');
- html += makeIconButton('fa-trash-alt icon-red', 'button-delete', pk, '{% trans "Delete line" %}', );
+ if (options.allow_edit) {
+ var pk = row.pk;
+ html += makeIconButton('fa-clone', 'button-duplicate', pk, '{% trans "Duplicate line" %}');
+ html += makeIconButton('fa-edit icon-blue', 'button-edit', pk, '{% trans "Edit line" %}');
+ html += makeIconButton('fa-trash-alt icon-red', 'button-delete', pk, '{% trans "Delete line" %}', );
+ }
html += `