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 <code@mjmair.com>
This commit is contained in:
Syogo-SuganoyaandMatthias Mair authored and GitHub committed 2026-12-01 07:39:52 +11:00
1 parent a80b87f584
commit 28f914e088
1 file changed
+6 -1
+6 -1
View File
@@ -22,6 +22,8 @@ export function bomItemFields({
}: { }: {
showAssembly?: boolean; showAssembly?: boolean;
}): ApiFormFieldSet { }): ApiFormFieldSet {
const user = useUserState();
const newPartFields = usePartFields({ const newPartFields = usePartFields({
create: true create: true
}); });
@@ -36,7 +38,10 @@ export function bomItemFields({
active: true, // Only show active parts when creating a new BOM item active: true, // Only show active parts when creating a new BOM item
component: true 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: { raw_amount: {
label: t`Quantity`, label: t`Quantity`,