mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Create new stock item
This commit is contained in:
parent
a09d0b6887
commit
3fb6b38930
@ -154,6 +154,9 @@ class APIFormField {
|
|||||||
return _constructBoolean();
|
return _constructBoolean();
|
||||||
case "related field":
|
case "related field":
|
||||||
return _constructRelatedField();
|
return _constructRelatedField();
|
||||||
|
case "float":
|
||||||
|
case "decimal":
|
||||||
|
return _constructFloatField();
|
||||||
case "choice":
|
case "choice":
|
||||||
return _constructChoiceField();
|
return _constructChoiceField();
|
||||||
default:
|
default:
|
||||||
@ -203,6 +206,34 @@ class APIFormField {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Construct a floating point numerical input field
|
||||||
|
Widget _constructFloatField() {
|
||||||
|
|
||||||
|
return TextFormField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: required ? label + "*" : label,
|
||||||
|
labelStyle: _labelStyle(),
|
||||||
|
helperText: helpText,
|
||||||
|
helperStyle: _helperStyle(),
|
||||||
|
hintText: placeholderText,
|
||||||
|
),
|
||||||
|
initialValue: (value ?? 0).toString(),
|
||||||
|
keyboardType: TextInputType.numberWithOptions(signed: true, decimal: true),
|
||||||
|
validator: (value) {
|
||||||
|
|
||||||
|
double? quantity = double.tryParse(value.toString()) ?? null;
|
||||||
|
|
||||||
|
if (quantity == null) {
|
||||||
|
return L10().numberInvalid;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSaved: (val) {
|
||||||
|
data["value"] = val;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Construct an input for a related field
|
// Construct an input for a related field
|
||||||
Widget _constructRelatedField() {
|
Widget _constructRelatedField() {
|
||||||
|
|
||||||
|
@ -108,6 +108,16 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
@override
|
@override
|
||||||
String WEB_URL = "stock/item/";
|
String WEB_URL = "stock/item/";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> formFields() {
|
||||||
|
return {
|
||||||
|
"part": {},
|
||||||
|
"location": {},
|
||||||
|
"status": {},
|
||||||
|
"quantity": {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, String> defaultGetFilters() {
|
Map<String, String> defaultGetFilters() {
|
||||||
|
|
||||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
|||||||
Subproject commit 8f8a04c7bd8ff02f2dbfa75ef168ce812503a31e
|
Subproject commit f4f7b95c28f82bfd4e398ec5bb5e35823102323c
|
@ -163,7 +163,31 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
|||||||
|
|
||||||
Future<void> _newStockItem(BuildContext context) async {
|
Future<void> _newStockItem(BuildContext context) async {
|
||||||
|
|
||||||
// TODO
|
int pk = location?.pk ?? -1;
|
||||||
|
|
||||||
|
if (pk <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InvenTreeStockItem().createForm(
|
||||||
|
context,
|
||||||
|
L10().stockItemCreate,
|
||||||
|
data: {
|
||||||
|
"location": pk,
|
||||||
|
},
|
||||||
|
onSuccess: (data) async {
|
||||||
|
if (data.containsKey("pk")) {
|
||||||
|
var item = InvenTreeStockItem.fromJson(data);
|
||||||
|
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => StockDetailWidget(item)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,6 +344,17 @@ List<Widget> detailTiles() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().stockItemCreate),
|
||||||
|
subtitle: Text(L10().stockItemCreateDetail),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.boxes, color: COLOR_CLICK),
|
||||||
|
onTap: () async {
|
||||||
|
_newStockItem(context);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user