2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 18:25:26 +00:00

Update status codes (#307)

* Extra error info when connecting to server

* Adds accessors for various types of status codes

* Cleanup / refactor stock status codes

- No longer need to duplicate these on the app

* improvements to purchase order list

- Add option to show closed orders
- Render order status

* Add purchase order status to order detail widget

* Update release notes

* Cleanup for imports

* linting fixes
This commit is contained in:
Oliver
2023-04-10 23:12:30 +10:00
committed by GitHub
parent efb7ff4170
commit 26b86a2194
10 changed files with 214 additions and 80 deletions

View File

@ -66,6 +66,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
Future<void> request(BuildContext context) async {
await order.reload();
await api.PurchaseOrderStatus.load();
lines = await order.getLineItems();
completedLines = 0;
@ -112,6 +114,12 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
title: Text(order.reference),
subtitle: Text(order.description),
leading: supplier == null ? null : InvenTreeAPI().getImage(supplier.thumbnail, width: 40, height: 40),
trailing: Text(
api.PurchaseOrderStatus.label(order.status),
style: TextStyle(
color: api.PurchaseOrderStatus.color(order.status)
),
)
)
);

View File

@ -125,11 +125,19 @@ class _PaginatedPurchaseOrderListState extends PaginatedSearchState<PaginatedPur
"target_date": L10().targetDate,
};
@override
Map<String, Map<String, dynamic>> get filterOptions => {
"outstanding": {
"label": L10().outstanding,
"help_text": L10().outstandingOrderDetail,
"tristate": true,
}
};
@override
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
params["outstanding"] = "true";
await InvenTreeAPI().PurchaseOrderStatus.load();
final page = await InvenTreePurchaseOrder().listPaginated(limit, offset, filters: params);
return page;
@ -151,7 +159,12 @@ class _PaginatedPurchaseOrderListState extends PaginatedSearchState<PaginatedPur
width: 40,
height: 40,
),
trailing: Text("${order.lineItemCount}"),
trailing: Text(
InvenTreeAPI().PurchaseOrderStatus.label(order.status),
style: TextStyle(
color: InvenTreeAPI().PurchaseOrderStatus.color(order.status),
),
),
onTap: () async {
Navigator.push(
context,

View File

@ -211,6 +211,8 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
@override
Future<void> request(BuildContext context) async {
await api.StockStatus.load();
stockShowHistory = await InvenTreeSettingsManager().getValue(INV_STOCK_SHOW_HISTORY, false) as bool;
final bool result = widget.item.pk > 0 && await widget.item.reload();
@ -565,9 +567,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
subtitle: Text("${widget.item.partDescription}"),
leading: InvenTreeAPI().getImage(widget.item.partImage),
trailing: Text(
widget.item.statusLabel(),
api.StockStatus.label(widget.item.status),
style: TextStyle(
color: widget.item.statusColor
color: api.StockStatus.color(widget.item.status),
)
),
onTap: () async {

View File

@ -33,7 +33,7 @@ class _StockItemHistoryDisplayState extends RefreshableState<StockItemHistoryWid
history.clear();
InvenTreeStockItemHistory().list(filters: {"item": "${item.pk}"}).then((List<InvenTreeModel> results) {
await InvenTreeStockItemHistory().list(filters: {"item": "${item.pk}"}).then((List<InvenTreeModel> results) {
for (var result in results) {
if (result is InvenTreeStockItemHistory) {
history.add(result);

View File

@ -95,6 +95,9 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
@override
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
// Ensure StockStatus codes are loaded
await InvenTreeAPI().StockStatus.load();
final page = await InvenTreeStockItem().listPaginated(
limit,
offset,
@ -120,7 +123,7 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
trailing: Text("${item.displayQuantity}",
style: TextStyle(
fontWeight: FontWeight.bold,
color: item.statusColor,
color: InvenTreeAPI().StockStatus.color(item.status),
),
),
onTap: () {