From a0b8795b27256152a80bd406ea20fbdb3ff2b791 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 19 Aug 2025 11:37:37 +1000 Subject: [PATCH] Allow purchase orders to be completed directly from the app (#686) * Allow purchase orders to be completed directly from the app * Code formatting --- CONTRIBUTING.md | 2 +- assets/release_notes.md | 1 + lib/l10n/app_en.arb | 6 ++++ lib/widget/order/purchase_order_detail.dart | 31 +++++++++++++++++++++ tasks.py | 5 ++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 248d20c8..859ab608 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,7 @@ We enforce consistent code formatting using Dart's built-in formatter. Before su 1. Fork the repository and create a feature branch 2. Make your changes 3. Ensure your code passes all tests and linting -4. Format your code using `fvm dart format` +4. Format your code using `invoke format` 5. Submit a pull request with a clear description of the changes 6. Address any review comments diff --git a/assets/release_notes.md b/assets/release_notes.md index 4eb7f293..e6319b35 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -1,6 +1,7 @@ ### TBD - ??? --- +- Allow purchase orders to be completed - Improved UX across the entire app - Fix bug which prevented display of part images for purchase order line items diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 7e02053b..fbac9091 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -261,6 +261,12 @@ "companies": "Companies", "@companies": {}, + "complete": "Complete", + "@complete": {}, + + "completeOrder": "Complete Order", + "@completeOrder": {}, + "completionDate": "Completion Date", "@completionDate": {}, diff --git a/lib/widget/order/purchase_order_detail.dart b/lib/widget/order/purchase_order_detail.dart index 47993179..4201cd36 100644 --- a/lib/widget/order/purchase_order_detail.dart +++ b/lib/widget/order/purchase_order_detail.dart @@ -1,6 +1,7 @@ import "package:flutter/material.dart"; import "package:flutter_speed_dial/flutter_speed_dial.dart"; import "package:flutter_tabler_icons/flutter_tabler_icons.dart"; +import "package:inventree/api_form.dart"; import "package:inventree/app_colors.dart"; import "package:inventree/barcode/barcode.dart"; @@ -122,6 +123,18 @@ class _PurchaseOrderDetailState ); } + if (widget.order.isOpen && !widget.order.isPending) { + actions.add( + SpeedDialChild( + child: Icon(TablerIcons.circle_check, color: Colors.green), + label: L10().completeOrder, + onTap: () async { + _completeOrder(context); + }, + ), + ); + } + if (widget.order.isOpen) { actions.add( SpeedDialChild( @@ -182,6 +195,24 @@ class _PurchaseOrderDetailState ); } + /// Complete this order + Future _completeOrder(BuildContext context) async { + Map> fields = {"accept_incomplete": {}}; + + String URL = "order/po/${widget.order.pk}/complete/"; + + launchApiForm( + context, + L10().completeOrder, + URL, + fields, + method: "POST", + onSuccess: (data) async { + refresh(context); + }, + ); + } + /// Cancel this order Future _cancelOrder(BuildContext context) async { confirmationDialog( diff --git a/tasks.py b/tasks.py index a34d0350..9c75e5a2 100644 --- a/tasks.py +++ b/tasks.py @@ -5,6 +5,11 @@ import sys from invoke import task +@task +def format(c): + """Code formatting using dart format.""" + c.run("fvm dart format lib") + @task def clean(c): """Clean flutter build."""