mirror of
https://github.com/inventree/inventree-app.git
synced 2026-08-14 15:34:21 +00:00
Fixes for build orders (#862)
* Fixes for build orders - Display build description - Improve status display * Bump version info * More fixes
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
## 0.25.1 - August 2026
|
||||
---
|
||||
|
||||
- Improvements for build order display
|
||||
|
||||
## 0.25.0 - July 2026
|
||||
---
|
||||
|
||||
|
||||
@@ -1927,11 +1927,15 @@ class InvenTreeAPI {
|
||||
InvenTreeStatusCode get SalesOrderStatus =>
|
||||
_get_status_class("order/so/status/");
|
||||
|
||||
InvenTreeStatusCode get BuildOrderStatus =>
|
||||
_get_status_class("build/status/");
|
||||
|
||||
void clearStatusCodeData() {
|
||||
StockHistoryStatus.data.clear();
|
||||
StockStatus.data.clear();
|
||||
PurchaseOrderStatus.data.clear();
|
||||
SalesOrderStatus.data.clear();
|
||||
BuildOrderStatus.data.clear();
|
||||
}
|
||||
|
||||
Future<void> fetchStatusCodeData({bool forceReload = true}) async {
|
||||
@@ -1939,6 +1943,7 @@ class InvenTreeAPI {
|
||||
StockStatus.load(forceReload: forceReload);
|
||||
PurchaseOrderStatus.load(forceReload: forceReload);
|
||||
SalesOrderStatus.load(forceReload: forceReload);
|
||||
BuildOrderStatus.load(forceReload: forceReload);
|
||||
}
|
||||
|
||||
int notification_counter = 0;
|
||||
|
||||
@@ -8,7 +8,6 @@ import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
|
||||
import "package:inventree/api.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/inventree/orders.dart";
|
||||
import "package:inventree/inventree/part.dart";
|
||||
@@ -111,11 +110,13 @@ class InvenTreeBuildOrder extends InvenTreeOrder {
|
||||
|
||||
// Status code handling
|
||||
// Note: These map to BuildStatus in backend/status_codes.py
|
||||
bool get isWaitingForBuild => status == BuildOrderStatus.PENDING;
|
||||
bool get isInProgress => status == BuildOrderStatus.PRODUCTION;
|
||||
bool get isComplete => status == BuildOrderStatus.COMPLETE;
|
||||
bool get isCancelled => status == BuildOrderStatus.CANCELLED;
|
||||
bool get isOnHold => status == BuildOrderStatus.ON_HOLD;
|
||||
bool get isWaitingForBuild =>
|
||||
api.BuildOrderStatus.isNameIn(status, ["PENDING"]);
|
||||
bool get isInProgress =>
|
||||
api.BuildOrderStatus.isNameIn(status, ["PRODUCTION"]);
|
||||
bool get isComplete => api.BuildOrderStatus.isNameIn(status, ["COMPLETE"]);
|
||||
bool get isCancelled => api.BuildOrderStatus.isNameIn(status, ["CANCELLED"]);
|
||||
bool get isOnHold => api.BuildOrderStatus.isNameIn(status, ["ON_HOLD"]);
|
||||
|
||||
// Can this build order be completed?
|
||||
bool get canCompleteOrder {
|
||||
@@ -365,53 +366,3 @@ class InvenTreeBuildItem extends InvenTreeModel {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Build Order Status Codes
|
||||
*/
|
||||
class BuildOrderStatus {
|
||||
// Status codes as defined in backend status_codes.py
|
||||
static const int PENDING = 10; // Build is pending / inactive
|
||||
static const int PRODUCTION = 20; // Build is active
|
||||
static const int ON_HOLD = 25; // Build is on hold
|
||||
static const int CANCELLED = 30; // Build was cancelled
|
||||
static const int COMPLETE = 40; // Build is complete
|
||||
|
||||
// Return a color based on the build status
|
||||
static Color getStatusColor(int status) {
|
||||
switch (status) {
|
||||
case PENDING:
|
||||
return COLOR_GRAY_LIGHT;
|
||||
case PRODUCTION:
|
||||
return COLOR_PROGRESS;
|
||||
case COMPLETE:
|
||||
return COLOR_SUCCESS;
|
||||
case CANCELLED:
|
||||
return COLOR_DANGER;
|
||||
case ON_HOLD:
|
||||
return COLOR_WARNING;
|
||||
default:
|
||||
return COLOR_GRAY_LIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
// Return a string based on the build status
|
||||
static String getStatusText(int status) {
|
||||
// TODO: This can be pulled from the API
|
||||
|
||||
switch (status) {
|
||||
case PENDING:
|
||||
return "Pending";
|
||||
case PRODUCTION:
|
||||
return "In Progress";
|
||||
case COMPLETE:
|
||||
return "Complete";
|
||||
case CANCELLED:
|
||||
return "Cancelled";
|
||||
case ON_HOLD:
|
||||
return "On Hold";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,23 +356,12 @@ class _BuildOrderDetailState extends RefreshableState<BuildOrderDetailWidget> {
|
||||
/// Header tile for the build order
|
||||
Widget headerTile(BuildContext context) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.order.reference,
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
BuildOrderStatus.getStatusText(widget.order.status),
|
||||
style: TextStyle(
|
||||
color: BuildOrderStatus.getStatusColor(widget.order.status),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: ListTile(
|
||||
title: Text(widget.order.reference),
|
||||
subtitle: Text(widget.order.description),
|
||||
trailing: LargeText(
|
||||
api.BuildOrderStatus.label(widget.order.status),
|
||||
color: api.BuildOrderStatus.color(widget.order.status),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -168,9 +168,9 @@ class _PaginatedBuildOrderListState
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
BuildOrderStatus.getStatusText(order.status),
|
||||
InvenTreeAPI().BuildOrderStatus.label(order.status),
|
||||
style: TextStyle(
|
||||
color: BuildOrderStatus.getStatusColor(order.status),
|
||||
color: InvenTreeAPI().BuildOrderStatus.color(order.status),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -61,15 +61,17 @@ class BuildOrderListItem extends StatelessWidget {
|
||||
vertical: 4.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: BuildOrderStatus.getStatusColor(
|
||||
order.status,
|
||||
).withValues(alpha: 0.2),
|
||||
color: InvenTreeAPI().BuildOrderStatus
|
||||
.color(order.status)
|
||||
.withValues(alpha: 0.2),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
child: Text(
|
||||
BuildOrderStatus.getStatusText(order.status),
|
||||
InvenTreeAPI().BuildOrderStatus.label(order.status),
|
||||
style: TextStyle(
|
||||
color: BuildOrderStatus.getStatusColor(order.status),
|
||||
color: InvenTreeAPI().BuildOrderStatus.color(
|
||||
order.status,
|
||||
),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
),
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: inventree
|
||||
description: InvenTree stock management
|
||||
|
||||
version: 0.25.0+123
|
||||
version: 0.25.1+124
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
|
||||
Reference in New Issue
Block a user