mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-02 15:28:53 +00:00
Further fixes for adjustStock function
This commit is contained in:
parent
5d0ffa059d
commit
ed5764336f
@ -458,8 +458,8 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
// TODO: Remove this function when we deprecate support for the old API
|
||||
Future<bool> adjustStock(BuildContext context, String endpoint, double q, {String? notes, int? location}) async {
|
||||
|
||||
// Serialized stock cannot be adjusted
|
||||
if (isSerialized()) {
|
||||
// Serialized stock cannot be adjusted (unless it is a "transfer")
|
||||
if (isSerialized() && location == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -468,8 +468,6 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
print("Adjust stock: ${endpoint}");
|
||||
|
||||
Map<String, dynamic> data = {};
|
||||
|
||||
// Note: Format of adjustment API was updated in API v14
|
||||
@ -482,7 +480,6 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
"quantity": "${quantity}",
|
||||
}
|
||||
],
|
||||
"notes": notes ?? ""
|
||||
};
|
||||
} else {
|
||||
// Legacy (<= 14) API
|
||||
@ -491,24 +488,22 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
"pk": "${pk}",
|
||||
"quantity": "${quantity}",
|
||||
},
|
||||
"notes": notes ?? "",
|
||||
};
|
||||
}
|
||||
|
||||
data["notes"] = notes ?? "";
|
||||
|
||||
if (location != null) {
|
||||
data["location"] = location;
|
||||
}
|
||||
|
||||
// Expected API return code depends on server API version
|
||||
final int expected_response = InvenTreeAPI().supportModernStockTransactions() ? 201 : 200;
|
||||
|
||||
var response = await api.post(
|
||||
endpoint,
|
||||
body: {
|
||||
"item": {
|
||||
"pk": "${pk}",
|
||||
"quantity": "${q}",
|
||||
},
|
||||
"notes": notes ?? "",
|
||||
},
|
||||
expectedStatusCode: 200
|
||||
body: data,
|
||||
expectedStatusCode: expected_response,
|
||||
);
|
||||
|
||||
return response.isValid();
|
||||
|
Loading…
x
Reference in New Issue
Block a user