mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-31 21:35:42 +00:00 
			
		
		
		
	Display "destination" in purchase order detail
(cherry picked from commit d0e4bf0246412938050f5de5a01b0b987cf9a0a2)
This commit is contained in:
		| @@ -226,7 +226,7 @@ class InvenTreePOLineItem extends InvenTreeOrderLine { | ||||
|    | ||||
|   String get purchasePriceCurrency => getString("purchase_price_currency"); | ||||
|  | ||||
|   int get destination => getInt("destination"); | ||||
|   int get destinationId => getInt("destination"); | ||||
|  | ||||
|   Map<String, dynamic> get destinationDetail => getMap("destination_detail"); | ||||
| } | ||||
|   | ||||
| @@ -1,8 +1,6 @@ | ||||
| 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/widget/dialogs.dart"; | ||||
| import "package:inventree/widget/order/po_line_list.dart"; | ||||
|  | ||||
| import "package:inventree/app_colors.dart"; | ||||
| import "package:inventree/barcode/barcode.dart"; | ||||
| @@ -10,8 +8,16 @@ import "package:inventree/barcode/purchase_order.dart"; | ||||
| import "package:inventree/helpers.dart"; | ||||
| import "package:inventree/l10.dart"; | ||||
|  | ||||
| import "package:inventree/inventree/model.dart"; | ||||
| import "package:inventree/inventree/company.dart"; | ||||
| import "package:inventree/inventree/stock.dart"; | ||||
| import "package:inventree/inventree/purchase_order.dart"; | ||||
|  | ||||
| import "package:inventree/widget/dialogs.dart"; | ||||
| import "package:inventree/widget/stock/location_display.dart"; | ||||
| import "package:inventree/widget/order/po_line_list.dart"; | ||||
|  | ||||
|  | ||||
| import "package:inventree/widget/attachment_widget.dart"; | ||||
| import "package:inventree/widget/company/company_detail.dart"; | ||||
| import "package:inventree/widget/notes_widget.dart"; | ||||
| @@ -42,6 +48,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | ||||
|    | ||||
|   List<InvenTreePOLineItem> lines = []; | ||||
|  | ||||
|   InvenTreeStockLocation? destination; | ||||
|  | ||||
|   int completedLines = 0; | ||||
|  | ||||
|   int attachmentCount = 0; | ||||
| @@ -258,6 +266,28 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | ||||
|         }); | ||||
|       } | ||||
|     }); | ||||
|  | ||||
|     if (api.supportsPurchaseOrderDestination && widget.order.destinationId > 0) { | ||||
|       InvenTreeStockLocation().get(widget.order.destinationId).then((InvenTreeModel? loc) { | ||||
|         if (mounted) { | ||||
|           if (loc != null && loc is InvenTreeStockLocation) { | ||||
|             setState(() { | ||||
|               destination = loc; | ||||
|             }); | ||||
|           } else { | ||||
|             setState(() { | ||||
|               destination = null; | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     } else { | ||||
|       if (mounted) { | ||||
|         setState(() { | ||||
|           destination = null; | ||||
|         }); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // Edit the currently displayed PurchaseOrder | ||||
| @@ -348,6 +378,23 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | ||||
|       )); | ||||
|     } | ||||
|  | ||||
|     // Order destination | ||||
|     if (destination != null) { | ||||
|       tiles.add(ListTile( | ||||
|         title: Text(L10().destination), | ||||
|         subtitle: Text(destination!.name), | ||||
|         leading: Icon(TablerIcons.map_pin, color: COLOR_ACTION), | ||||
|         onTap: () => { | ||||
|           Navigator.push( | ||||
|             context, | ||||
|             MaterialPageRoute( | ||||
|               builder: (context) => LocationDisplayWidget(destination!) | ||||
|             ) | ||||
|           ) | ||||
|         } | ||||
|       )); | ||||
|     } | ||||
|  | ||||
|     Color lineColor = completedLines < widget.order.lineItemCount ? COLOR_WARNING : COLOR_SUCCESS; | ||||
|  | ||||
|     tiles.add(ListTile( | ||||
| @@ -444,5 +491,4 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | ||||
|       PaginatedStockItemList({"purchase_order": widget.order.pk.toString()}), | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
| } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user