2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

Order hold (#515)
Some checks are pending
Android / build (push) Waiting to run
CI / test (push) Waiting to run
iOS / build (push) Waiting to run

* Add support for "ON_HOLD" status for orders

* Bump version and release notes

* Fix import
This commit is contained in:
Oliver 2024-08-07 21:11:40 +10:00 committed by GitHub
parent 693b4a4fce
commit 42de3fd7d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 92 additions and 9 deletions

View File

@ -1,3 +1,9 @@
### 0.16.2 - August 2024
---
- Support "ON_HOLD" status for Purchase Orders
- Support "ON_HOLD" status for Sales Orders
### 0.16.1 - July 2024
---

View File

@ -87,9 +87,9 @@ class InvenTreePurchaseOrder extends InvenTreeOrder {
String get supplierReference => getString("supplier_reference");
bool get isOpen => api.PurchaseOrderStatus.isNameIn(status, ["PENDING", "PLACED"]);
bool get isOpen => api.PurchaseOrderStatus.isNameIn(status, ["PENDING", "PLACED", "ON_HOLD"]);
bool get isPending => api.PurchaseOrderStatus.isNameIn(status, ["PENDING"]);
bool get isPending => api.PurchaseOrderStatus.isNameIn(status, ["PENDING", "ON_HOLD"]);
bool get isPlaced => api.PurchaseOrderStatus.isNameIn(status, ["PLACED"]);

View File

@ -78,6 +78,23 @@ class InvenTreeSalesOrder extends InvenTreeOrder {
};
}
Future<void> issueOrder() async {
if (!isPending) {
return;
}
await api.post("${url}issue/", expectedStatusCode: 201);
}
/// Mark this order as "cancelled"
Future<void> cancelOrder() async {
if (!isOpen) {
return;
}
await api.post("${url}cancel/", expectedStatusCode: 201);
}
int get customerId => getInt("customer");
InvenTreeCompany? get customer {
@ -92,7 +109,11 @@ class InvenTreeSalesOrder extends InvenTreeOrder {
String get customerReference => getString("customer_reference");
bool get isOpen => api.SalesOrderStatus.isNameIn(status, ["PENDING", "IN_PROGRESS"]);
bool get isOpen => api.SalesOrderStatus.isNameIn(status, ["PENDING", "IN_PROGRESS", "ON_HOLD"]);
bool get isPending => api.SalesOrderStatus.isNameIn(status, ["PENDING", "ON_HOLD"]);
bool get isInProgress => api.SalesOrderStatus.isNameIn(status, ["IN_PROGRESS"]);
bool get isComplete => api.SalesOrderStatus.isNameIn(status, ["SHIPPED"]);

View File

@ -163,7 +163,6 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
acceptText: L10().cancel,
onAccept: () async {
await widget.order.cancelOrder().then((dynamic) {
print("callback");
refresh(context);
});
}

View File

@ -14,6 +14,7 @@ import "package:inventree/l10.dart";
import "package:inventree/app_colors.dart";
import "package:inventree/widget/attachment_widget.dart";
import "package:inventree/widget/dialogs.dart";
import "package:inventree/widget/notes_widget.dart";
import "package:inventree/widget/snacks.dart";
import "package:inventree/widget/company/company_detail.dart";
@ -99,15 +100,71 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
);
}
/// Issue this order
Future<void> _issueOrder(BuildContext context) async {
confirmationDialog(
L10().issueOrder, "",
icon: FontAwesomeIcons.paperPlane,
color: Colors.blue,
acceptText: L10().issue,
onAccept: () async {
await widget.order.issueOrder().then((dynamic) {
refresh(context);
});
}
);
}
/// Cancel this order
Future<void> _cancelOrder(BuildContext context) async {
confirmationDialog(
L10().cancelOrder, "",
icon: FontAwesomeIcons.circleXmark,
color: Colors.red,
acceptText: L10().cancel,
onAccept: () async {
await widget.order.cancelOrder().then((dynamic) {
refresh(context);
});
}
);
}
@override
List<SpeedDialChild> actionButtons(BuildContext context) {
List<SpeedDialChild> actions = [];
// Add line item
if (widget.order.isOpen && InvenTreeSOLineItem().canCreate) {
if (widget.order.isPending) {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.circlePlus),
child: FaIcon(FontAwesomeIcons.paperPlane, color: Colors.blue),
label: L10().issueOrder,
onTap: () async {
_issueOrder(context);
}
)
);
}
if (widget.order.isOpen) {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.circleXmark, color: Colors.red),
label: L10().cancelOrder,
onTap: () async {
_cancelOrder(context);
}
)
);
}
// Add line item
if (widget.order.isInProgress && InvenTreeSOLineItem().canCreate) {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.circlePlus, color: Colors.green),
label: L10().lineItemAdd,
onTap: () async {
_addLineItem(context);
@ -117,7 +174,7 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.circlePlus),
child: FaIcon(FontAwesomeIcons.truck, color: Colors.green),
label: L10().shipmentAdd,
onTap: () async {
_addShipment(context);
@ -133,7 +190,7 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
List<SpeedDialChild> barcodeButtons(BuildContext context) {
List<SpeedDialChild> actions = [];
if (widget.order.isOpen && InvenTreeSOLineItem().canCreate) {
if (widget.order.isInProgress && InvenTreeSOLineItem().canCreate) {
actions.add(
SpeedDialChild(
child: Icon(Icons.barcode_reader),

View File

@ -1,7 +1,7 @@
name: inventree
description: InvenTree stock management
version: 0.16.1+86
version: 0.16.2+87
environment:
sdk: ">=2.19.5 <3.13.0"