From 28f914e088b1e6b291a2cfea2fdc1e728f253d0a Mon Sep 17 00:00:00 2001 From: Syogo-Suganoya <55225064+Syogo-Suganoya@users.noreply.github.com> Date: Tue, 1 Dec 2026 05:39:52 +0900 Subject: [PATCH] Only allow inline part creation in the BOM form with part add permission (#13419) The BOM item form offers an inline button to create a new part for the sub_part field. A user with BOM add permission but without part add permission could see this button, but the request to create the part was rejected by the server (403). Only provide the inline create fields when the user has the part add role. Co-authored-by: Matthias Mair --- src/frontend/src/forms/BomForms.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/forms/BomForms.tsx b/src/frontend/src/forms/BomForms.tsx index 3a3d346b7d..d1cca5fca1 100644 --- a/src/frontend/src/forms/BomForms.tsx +++ b/src/frontend/src/forms/BomForms.tsx @@ -22,6 +22,8 @@ export function bomItemFields({ }: { showAssembly?: boolean; }): ApiFormFieldSet { + const user = useUserState(); + const newPartFields = usePartFields({ create: true }); @@ -36,7 +38,10 @@ export function bomItemFields({ active: true, // Only show active parts when creating a new BOM item component: true }, - addCreateFields: newPartFields + // A new part can only be created if the user has permission to do so + addCreateFields: user.hasAddRole(UserRoles.part) + ? newPartFields + : undefined }, raw_amount: { label: t`Quantity`,