mirror of
https://github.com/inventree/InvenTree.git
synced 2026-12-03 12:51:34 +00:00
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:
1 parent
a80b87f584
commit
28f914e088
1 file changed
+6
-1
@@ -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`,
|
||||
|
||||
Reference in new issue
Block a user