mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-31 13:25:40 +00:00 
			
		
		
		
	PO Contact (#305)
* Bug fix in API forms - Allow form fields to specify custom filters at runtime * Add "contact" model to purchase order edit form * Add action to create new purchase order from list widget * widget updates for purchase order
This commit is contained in:
		| @@ -83,11 +83,19 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   // Edit the currently displayed PurchaseOrder | ||||
|   Future <void> editOrder(BuildContext context) async { | ||||
|     var fields = order.formFields(); | ||||
|     fields.remove("supplier"); | ||||
|  | ||||
|     if (!api.supportsContactModel) { | ||||
|       fields.remove("contact"); | ||||
|     } | ||||
|  | ||||
|     order.editForm( | ||||
|       context, | ||||
|       L10().purchaseOrderEdit, | ||||
|       fields: fields, | ||||
|       onSuccess: (data) async { | ||||
|         refresh(context); | ||||
|         showSnackIcon(L10().purchaseOrderUpdated, success: true); | ||||
| @@ -143,8 +151,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | ||||
|  | ||||
|     tiles.add(ListTile( | ||||
|       title: Text(L10().lineItems), | ||||
|       leading: FaIcon(FontAwesomeIcons.clipboardList, color: COLOR_CLICK), | ||||
|       trailing: Text("${order.lineItemCount}"), | ||||
|       leading: FaIcon(FontAwesomeIcons.clipboardCheck), | ||||
|       trailing: Text("${completedLines} /  ${order.lineItemCount}"), | ||||
|     )); | ||||
|  | ||||
|     tiles.add(ListTile( | ||||
| @@ -155,12 +163,6 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | ||||
|       ), | ||||
|     )); | ||||
|  | ||||
|     tiles.add(ListTile( | ||||
|       title: Text(L10().received), | ||||
|       leading: FaIcon(FontAwesomeIcons.clipboardCheck, color: COLOR_CLICK), | ||||
|       trailing: Text("${completedLines}"), | ||||
|     )); | ||||
|  | ||||
|     if (order.issueDate.isNotEmpty) { | ||||
|       tiles.add(ListTile( | ||||
|         title: Text(L10().issueDate), | ||||
| @@ -312,8 +314,6 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | ||||
|  | ||||
|     List<Widget> tiles = []; | ||||
|  | ||||
|     tiles.add(headerTile(context)); | ||||
|  | ||||
|     for (var line in lines) { | ||||
|  | ||||
|       InvenTreeSupplierPart? supplierPart = line.supplierPart; | ||||
| @@ -347,9 +347,6 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | ||||
|               ), | ||||
|             ), | ||||
|             onTap: () { | ||||
|               // TODO: ? | ||||
|             }, | ||||
|             onLongPress: () { | ||||
|               lineItemMenu(context, line); | ||||
|             }, | ||||
|           ) | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| import "package:flutter/material.dart"; | ||||
| import "package:flutter_speed_dial/flutter_speed_dial.dart"; | ||||
| import "package:font_awesome_flutter/font_awesome_flutter.dart"; | ||||
|  | ||||
| import "package:inventree/inventree/company.dart"; | ||||
| @@ -47,6 +48,51 @@ class _PurchaseOrderListWidgetState extends RefreshableState<PurchaseOrderListWi | ||||
|     ) | ||||
|   ]; | ||||
|  | ||||
|   @override | ||||
|   List<SpeedDialChild> actionButtons(BuildContext context) { | ||||
|     List<SpeedDialChild> actions = []; | ||||
|  | ||||
|     if (api.checkPermission("purchase_order", "add")) { | ||||
|       actions.add( | ||||
|         SpeedDialChild( | ||||
|           child: FaIcon(FontAwesomeIcons.circlePlus), | ||||
|           label: L10().purchaseOrderCreate, | ||||
|           onTap: () { | ||||
|             createPurchaseOrder(context); | ||||
|           } | ||||
|         ) | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     return actions; | ||||
|   } | ||||
|  | ||||
|   Future<void> createPurchaseOrder(BuildContext context) async { | ||||
|     var fields = InvenTreePurchaseOrder().formFields(); | ||||
|  | ||||
|     fields.remove("contact"); | ||||
|  | ||||
|     InvenTreePurchaseOrder().createForm( | ||||
|       context, | ||||
|       L10().purchaseOrderCreate, | ||||
|       fields: fields, | ||||
|       onSuccess: (result) async { | ||||
|         Map<String, dynamic> data = result as Map<String, dynamic>; | ||||
|  | ||||
|         if (data.containsKey("pk")) { | ||||
|           var order = InvenTreePurchaseOrder.fromJson(data); | ||||
|  | ||||
|           Navigator.push( | ||||
|             context, | ||||
|             MaterialPageRoute( | ||||
|               builder: (context) => PurchaseOrderDetailWidget(order) | ||||
|             ) | ||||
|           ); | ||||
|         } | ||||
|       } | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   Widget getBody(BuildContext context) { | ||||
|     return PaginatedPurchaseOrderList(filters, showFilterOptions); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user