From 02876f3c541388826d35167ab008cc3bb448499a Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
 <41898282+github-actions[bot]@users.noreply.github.com>
Date: Mon, 24 Mar 2025 20:45:58 +1100
Subject: [PATCH] [UI] Edit fix (#9367) (#9368)

* Fix for editing stock location

* Fix for editing part category

(cherry picked from commit 8997f193c925e5b31e4deace56167ac45cf599d2)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
---
 src/frontend/src/pages/part/CategoryDetail.tsx  | 4 +++-
 src/frontend/src/pages/stock/LocationDetail.tsx | 5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/frontend/src/pages/part/CategoryDetail.tsx b/src/frontend/src/pages/part/CategoryDetail.tsx
index a8fa7a9cb9..250cd1f298 100644
--- a/src/frontend/src/pages/part/CategoryDetail.tsx
+++ b/src/frontend/src/pages/part/CategoryDetail.tsx
@@ -341,7 +341,9 @@ export default function CategoryDetail() {
             }}
             actions={categoryActions}
             editAction={editCategory.open}
-            editEnabled={user.hasChangePermission(ModelType.partcategory)}
+            editEnabled={
+              !!category?.pk && user.hasChangePermission(ModelType.partcategory)
+            }
           />
           <PanelGroup
             pageKey='partcategory'
diff --git a/src/frontend/src/pages/stock/LocationDetail.tsx b/src/frontend/src/pages/stock/LocationDetail.tsx
index a5ee51f0c9..cebc6c8e4b 100644
--- a/src/frontend/src/pages/stock/LocationDetail.tsx
+++ b/src/frontend/src/pages/stock/LocationDetail.tsx
@@ -381,7 +381,10 @@ export default function Stock() {
             icon={location?.icon && <ApiIcon name={location?.icon} />}
             actions={locationActions}
             editAction={editLocation.open}
-            editEnabled={user.hasChangePermission(ModelType.stocklocation)}
+            editEnabled={
+              !!location?.pk &&
+              user.hasChangePermission(ModelType.stocklocation)
+            }
             breadcrumbs={breadcrumbs}
             breadcrumbAction={() => {
               setTreeOpen(true);