From 0c55bdfa21d5154fa96bdb67556d286c24c12c9b Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 6 May 2026 01:22:36 +0200 Subject: [PATCH 1/4] Lock notes on orders if they are completed Fixes #11879 --- src/frontend/src/components/editors/NotesEditor.tsx | 2 +- src/frontend/src/pages/build/BuildDetail.tsx | 4 +++- src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx | 4 +++- src/frontend/src/pages/sales/SalesOrderDetail.tsx | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/components/editors/NotesEditor.tsx b/src/frontend/src/components/editors/NotesEditor.tsx index afdb3d2c055c..7f1920ac9a62 100644 --- a/src/frontend/src/components/editors/NotesEditor.tsx +++ b/src/frontend/src/components/editors/NotesEditor.tsx @@ -217,7 +217,7 @@ export default function NotesEditor({ const sibling = mdeInstance?.codemirror.getWrapperElement()?.nextSibling; - if (sibling != null) { + if (sibling != null && editable != false) { EasyMDE.togglePreview(mdeInstance); } } diff --git a/src/frontend/src/pages/build/BuildDetail.tsx b/src/frontend/src/pages/build/BuildDetail.tsx index eb3b84117ec0..8e748638205d 100644 --- a/src/frontend/src/pages/build/BuildDetail.tsx +++ b/src/frontend/src/pages/build/BuildDetail.tsx @@ -569,7 +569,9 @@ export default function BuildDetail() { NotesPanel({ model_type: ModelType.build, model_id: build.pk, - has_note: !!build.notes + has_note: !!build.notes, + // TODO @matmair - change API to include a "locked" attribute that we can check here + editable: build.status == 40 ? false : undefined }) ]; }, [ diff --git a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx index 30500dbdc7d7..53463d3afbc5 100644 --- a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx +++ b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx @@ -410,7 +410,9 @@ export default function PurchaseOrderDetail() { NotesPanel({ model_type: ModelType.purchaseorder, model_id: order.pk, - has_note: !!order.notes + has_note: !!order.notes, + // TODO @matmair - change API to include a "locked" attribute that we can check here + editable: order.status == 30 ? false : undefined }) ]; }, [order, id, user]); diff --git a/src/frontend/src/pages/sales/SalesOrderDetail.tsx b/src/frontend/src/pages/sales/SalesOrderDetail.tsx index fa3b1a709367..a629b360736a 100644 --- a/src/frontend/src/pages/sales/SalesOrderDetail.tsx +++ b/src/frontend/src/pages/sales/SalesOrderDetail.tsx @@ -448,7 +448,9 @@ export default function SalesOrderDetail() { NotesPanel({ model_type: ModelType.salesorder, model_id: order.pk, - has_note: !!order.notes + has_note: !!order.notes, + // TODO @matmair - change API to include a "locked" attribute that we can check here + editable: order.status == 30 ? false : undefined }) ]; }, [order, id, user, soStatus, user]); From 237a7b1f541ad8e528757f4e1b50d17bf155e515 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 6 May 2026 01:47:24 +0200 Subject: [PATCH 2/4] also check setting --- src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx | 6 +++++- src/frontend/src/pages/sales/SalesOrderDetail.tsx | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx index 53463d3afbc5..aac348b43506 100644 --- a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx +++ b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx @@ -412,7 +412,11 @@ export default function PurchaseOrderDetail() { model_id: order.pk, has_note: !!order.notes, // TODO @matmair - change API to include a "locked" attribute that we can check here - editable: order.status == 30 ? false : undefined + editable: + order.status == 30 && + !globalSettings.isSet('PURCHASEORDER_EDIT_COMPLETED_ORDERS') + ? false + : undefined }) ]; }, [order, id, user]); diff --git a/src/frontend/src/pages/sales/SalesOrderDetail.tsx b/src/frontend/src/pages/sales/SalesOrderDetail.tsx index a629b360736a..fc94b2d26e55 100644 --- a/src/frontend/src/pages/sales/SalesOrderDetail.tsx +++ b/src/frontend/src/pages/sales/SalesOrderDetail.tsx @@ -450,7 +450,11 @@ export default function SalesOrderDetail() { model_id: order.pk, has_note: !!order.notes, // TODO @matmair - change API to include a "locked" attribute that we can check here - editable: order.status == 30 ? false : undefined + editable: + order.status == 30 && + !globalSettings.isSet('SALESORDER_EDIT_COMPLETED_ORDERS') + ? false + : undefined }) ]; }, [order, id, user, soStatus, user]); From 90d4bd73e93746747ecec11643b9e6958290f4e1 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 6 May 2026 13:44:16 +0200 Subject: [PATCH 3/4] use statuscode object --- src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx | 2 +- src/frontend/src/pages/sales/SalesOrderDetail.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx index aac348b43506..8a0025a9c6fe 100644 --- a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx +++ b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx @@ -413,7 +413,7 @@ export default function PurchaseOrderDetail() { has_note: !!order.notes, // TODO @matmair - change API to include a "locked" attribute that we can check here editable: - order.status == 30 && + order.status == poStatus.COMPLETE && !globalSettings.isSet('PURCHASEORDER_EDIT_COMPLETED_ORDERS') ? false : undefined diff --git a/src/frontend/src/pages/sales/SalesOrderDetail.tsx b/src/frontend/src/pages/sales/SalesOrderDetail.tsx index fc94b2d26e55..6846948a4ce9 100644 --- a/src/frontend/src/pages/sales/SalesOrderDetail.tsx +++ b/src/frontend/src/pages/sales/SalesOrderDetail.tsx @@ -451,7 +451,7 @@ export default function SalesOrderDetail() { has_note: !!order.notes, // TODO @matmair - change API to include a "locked" attribute that we can check here editable: - order.status == 30 && + order.status == soStatus.COMPLETE && !globalSettings.isSet('SALESORDER_EDIT_COMPLETED_ORDERS') ? false : undefined From 953855b4032c114a1f1c00c1332ed3a91a2a3ff2 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 6 May 2026 13:46:43 +0200 Subject: [PATCH 4/4] remove build lock --- src/frontend/src/pages/build/BuildDetail.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/frontend/src/pages/build/BuildDetail.tsx b/src/frontend/src/pages/build/BuildDetail.tsx index 8e748638205d..eb3b84117ec0 100644 --- a/src/frontend/src/pages/build/BuildDetail.tsx +++ b/src/frontend/src/pages/build/BuildDetail.tsx @@ -569,9 +569,7 @@ export default function BuildDetail() { NotesPanel({ model_type: ModelType.build, model_id: build.pk, - has_note: !!build.notes, - // TODO @matmair - change API to include a "locked" attribute that we can check here - editable: build.status == 40 ? false : undefined + has_note: !!build.notes }) ]; }, [