mirror of
https://github.com/inventree/InvenTree.git
synced 2026-01-28 09:03:41 +00:00
@@ -1038,6 +1038,30 @@ function stockMergeFields(items: any[]): ApiFormFieldSet {
|
||||
|
||||
const records = Object.fromEntries(items.map((item) => [item.pk, item]));
|
||||
|
||||
// Extract all non-null location values from the items
|
||||
const locationValues = [
|
||||
...new Set(
|
||||
items.filter((item) => item.location).map((item) => item.location)
|
||||
)
|
||||
];
|
||||
|
||||
// Extract all non-null default location values from the items
|
||||
const defaultLocationValues = [
|
||||
...new Set(
|
||||
items
|
||||
.filter((item) => item.part_detail?.default_location)
|
||||
.map((item) => item.part_detail?.default_location)
|
||||
)
|
||||
];
|
||||
|
||||
// Select a default location value
|
||||
const defaultLocation =
|
||||
locationValues.length === 1
|
||||
? locationValues[0]
|
||||
: defaultLocationValues.length === 1
|
||||
? defaultLocationValues[0]
|
||||
: undefined;
|
||||
|
||||
const fields: ApiFormFieldSet = {
|
||||
items: {
|
||||
field_type: 'table',
|
||||
@@ -1067,7 +1091,7 @@ function stockMergeFields(items: any[]): ApiFormFieldSet {
|
||||
]
|
||||
},
|
||||
location: {
|
||||
default: items[0]?.part_detail?.default_location,
|
||||
default: defaultLocation,
|
||||
filters: {
|
||||
structural: false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user