mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Stock transfer now works
This commit is contained in:
parent
af104717ab
commit
c4d8b5ce1c
@ -218,6 +218,20 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<http.Response> transferStock(double q, int location, {String notes}) async {
|
||||||
|
|
||||||
|
if ((q == null) || (q > quantity)) q = quantity;
|
||||||
|
|
||||||
|
return api.post("/stock/transfer/", body: {
|
||||||
|
"item": {
|
||||||
|
"pk": "${pk}",
|
||||||
|
"quantity": "${q}",
|
||||||
|
},
|
||||||
|
"location": "${location}",
|
||||||
|
"notes": notes ?? '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
var response = await item.countStock(quantity, notes: _notesController.text);
|
var response = await item.countStock(quantity, notes: _notesController.text);
|
||||||
_notesController.clear();
|
_notesController.clear();
|
||||||
|
|
||||||
// TODO - Handle error cases
|
// TODO - Handle error cases, timeout, etc
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
@ -218,8 +218,20 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _transferStock(int location) {
|
void _transferStock(int location) async {
|
||||||
// TODO
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
|
double quantity = double.parse(_quantityController.text);
|
||||||
|
String notes = _notesController.text;
|
||||||
|
|
||||||
|
_quantityController.clear();
|
||||||
|
_notesController.clear();
|
||||||
|
|
||||||
|
var response = await item.transferStock(quantity, location, notes: notes);
|
||||||
|
|
||||||
|
// TODO - Error handling
|
||||||
|
refresh();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _transferStockDialog() async {
|
void _transferStockDialog() async {
|
||||||
@ -238,7 +250,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
child: Text("Transfer"),
|
child: Text("Transfer"),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_moveStockKey.currentState.validate()) {
|
if (_moveStockKey.currentState.validate()) {
|
||||||
// TODO - Transfer!
|
_moveStockKey.currentState.save();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -280,6 +292,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
selectedLocation = suggestion as InvenTreeStockLocation;
|
selectedLocation = suggestion as InvenTreeStockLocation;
|
||||||
_selectedController.text = selectedLocation.pathstring;
|
_selectedController.text = selectedLocation.pathstring;
|
||||||
},
|
},
|
||||||
|
onSaved: (value) {
|
||||||
|
_transferStock(selectedLocation.pk);
|
||||||
|
},
|
||||||
itemBuilder: (context, suggestion) {
|
itemBuilder: (context, suggestion) {
|
||||||
var location = suggestion as InvenTreeStockLocation;
|
var location = suggestion as InvenTreeStockLocation;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user