mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Set default location for part
- Used as "default" when creating new StockItem for that part
This commit is contained in:
parent
baa197c68c
commit
cbb668687e
@ -395,7 +395,7 @@ class APIFormField {
|
|||||||
// Render a "related field" based on the "model" type
|
// Render a "related field" based on the "model" type
|
||||||
|
|
||||||
// Convert to JSON
|
// Convert to JSON
|
||||||
Map<String, dynamic> data = item as Map<String, dynamic>;
|
var data = Map<String, dynamic>.from((item ?? {}) as Map);
|
||||||
|
|
||||||
switch (model) {
|
switch (model) {
|
||||||
case "part":
|
case "part":
|
||||||
|
@ -139,9 +139,9 @@ class InvenTreePart extends InvenTreeModel {
|
|||||||
"keywords": {},
|
"keywords": {},
|
||||||
"link": {},
|
"link": {},
|
||||||
|
|
||||||
// Parent category
|
"category": {},
|
||||||
"category": {
|
|
||||||
},
|
"default_location": {},
|
||||||
|
|
||||||
"units": {},
|
"units": {},
|
||||||
|
|
||||||
@ -242,6 +242,8 @@ class InvenTreePart extends InvenTreeModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int? get defaultLocation => jsondata["default_location"] as int?;
|
||||||
|
|
||||||
// Get the number of stock on order for this Part
|
// Get the number of stock on order for this Part
|
||||||
double get onOrder => double.tryParse(jsondata["ordering"].toString()) ?? 0;
|
double get onOrder => double.tryParse(jsondata["ordering"].toString()) ?? 0;
|
||||||
|
|
||||||
|
@ -400,6 +400,12 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
|
|
||||||
fields["part"]["hidden"] = true;
|
fields["part"]["hidden"] = true;
|
||||||
|
|
||||||
|
int? default_location = part.defaultLocation;
|
||||||
|
|
||||||
|
if (default_location != null) {
|
||||||
|
fields["location"]["value"] = default_location;
|
||||||
|
}
|
||||||
|
|
||||||
InvenTreeStockItem().createForm(
|
InvenTreeStockItem().createForm(
|
||||||
context,
|
context,
|
||||||
L10().stockItemCreate,
|
L10().stockItemCreate,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user