mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-30 21:05:42 +00:00 
			
		
		
		
	Display and edit project code for purchase orders
This commit is contained in:
		| @@ -15,6 +15,7 @@ import "package:inventree/l10.dart"; | |||||||
|  |  | ||||||
| import "package:inventree/inventree/company.dart"; | import "package:inventree/inventree/company.dart"; | ||||||
| import "package:inventree/inventree/part.dart"; | import "package:inventree/inventree/part.dart"; | ||||||
|  | import "package:inventree/inventree/project_code.dart"; | ||||||
| import "package:inventree/inventree/sentry.dart"; | import "package:inventree/inventree/sentry.dart"; | ||||||
| import "package:inventree/inventree/stock.dart"; | import "package:inventree/inventree/stock.dart"; | ||||||
|  |  | ||||||
| @@ -667,6 +668,13 @@ class APIFormField { | |||||||
|             height: 40 |             height: 40 | ||||||
|           ) |           ) | ||||||
|         ); |         ); | ||||||
|  |       case "projectcode": | ||||||
|  |         var project_code = InvenTreeProjectCode.fromJson(data); | ||||||
|  |         return ListTile( | ||||||
|  |           title: Text(project_code.code), | ||||||
|  |           subtitle: Text(project_code.description), | ||||||
|  |           leading: FaIcon(FontAwesomeIcons.list) | ||||||
|  |         ); | ||||||
|       default: |       default: | ||||||
|         return ListTile( |         return ListTile( | ||||||
|           title: Text( |           title: Text( | ||||||
|   | |||||||
| @@ -335,7 +335,7 @@ class InvenTreePart extends InvenTreeModel { | |||||||
|     double get building => getDouble("building"); |     double get building => getDouble("building"); | ||||||
|  |  | ||||||
|     // Get the number of BOMs this Part is used in (if it is a component) |     // Get the number of BOMs this Part is used in (if it is a component) | ||||||
|     int get usedInCount => getInt("used_in"); |     int get usedInCount => jsondata.containsKey("used_in") ? getInt("used_in", backup: 0) : 0; | ||||||
|  |  | ||||||
|     bool get isAssembly => getBool("assembly"); |     bool get isAssembly => getBool("assembly"); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,4 +23,6 @@ class InvenTreeProjectCode extends InvenTreeModel { | |||||||
|       "description": {}, |       "description": {}, | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   String get code => getString("code"); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -34,6 +34,7 @@ class InvenTreePurchaseOrder extends InvenTreeModel { | |||||||
|       }, |       }, | ||||||
|       "supplier_reference": {}, |       "supplier_reference": {}, | ||||||
|       "description": {}, |       "description": {}, | ||||||
|  |       "project_code": {}, | ||||||
|       "target_date": {}, |       "target_date": {}, | ||||||
|       "link": {}, |       "link": {}, | ||||||
|       "responsible": {}, |       "responsible": {}, | ||||||
| @@ -77,6 +78,15 @@ class InvenTreePurchaseOrder extends InvenTreeModel { | |||||||
|  |  | ||||||
|   int get supplierId => getInt("supplier"); |   int get supplierId => getInt("supplier"); | ||||||
|  |  | ||||||
|  |   // Project code information | ||||||
|  |   int get projectCodeId => getInt("project_code"); | ||||||
|  |  | ||||||
|  |   String get projectCode => getString("code", subKey: "project_code_detail"); | ||||||
|  |  | ||||||
|  |   String get projectCodeDescription => getString("description", subKey: "project_code_detail"); | ||||||
|  |  | ||||||
|  |   bool get hasProjectCode => projectCode.isNotEmpty; | ||||||
|  |  | ||||||
|   InvenTreeCompany? get supplier { |   InvenTreeCompany? get supplier { | ||||||
|  |  | ||||||
|     dynamic supplier_detail = jsondata["supplier_detail"]; |     dynamic supplier_detail = jsondata["supplier_detail"]; | ||||||
|   | |||||||
| @@ -759,6 +759,9 @@ | |||||||
|   "profileTapToCreate": "Tap to create or select a profile", |   "profileTapToCreate": "Tap to create or select a profile", | ||||||
|   "@profileTapToCreate": {}, |   "@profileTapToCreate": {}, | ||||||
|  |  | ||||||
|  |   "projectCode": "Project Code", | ||||||
|  |   "@projectCode": {}, | ||||||
|  |  | ||||||
|   "purchaseOrder": "Purchase Order", |   "purchaseOrder": "Purchase Order", | ||||||
|   "@purchaseOrder": {}, |   "@purchaseOrder": {}, | ||||||
|  |  | ||||||
|   | |||||||
| @@ -43,6 +43,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | |||||||
|  |  | ||||||
|   int attachmentCount = 0; |   int attachmentCount = 0; | ||||||
|  |  | ||||||
|  |   bool supportProjectCodes = false; | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   String getAppBarTitle() => L10().purchaseOrder; |   String getAppBarTitle() => L10().purchaseOrder; | ||||||
|  |  | ||||||
| @@ -139,6 +141,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | |||||||
|  |  | ||||||
|     lines = await order.getLineItems(); |     lines = await order.getLineItems(); | ||||||
|  |  | ||||||
|  |     supportProjectCodes = api.supportsProjectCodes && await api.getGlobalBooleanSetting("PROJECT_CODES_ENABLED"); | ||||||
|  |  | ||||||
|     completedLines = 0; |     completedLines = 0; | ||||||
|  |  | ||||||
|     for (var line in lines) { |     for (var line in lines) { | ||||||
| @@ -157,12 +161,20 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | |||||||
|   // Edit the currently displayed PurchaseOrder |   // Edit the currently displayed PurchaseOrder | ||||||
|   Future <void> editOrder(BuildContext context) async { |   Future <void> editOrder(BuildContext context) async { | ||||||
|     var fields = order.formFields(); |     var fields = order.formFields(); | ||||||
|  |  | ||||||
|  |     // Cannot edit supplier field from here | ||||||
|     fields.remove("supplier"); |     fields.remove("supplier"); | ||||||
|  |  | ||||||
|  |     // Contact model not supported by server | ||||||
|     if (!api.supportsContactModel) { |     if (!api.supportsContactModel) { | ||||||
|       fields.remove("contact"); |       fields.remove("contact"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     // ProjectCode model not supported by server | ||||||
|  |     if (!supportProjectCodes) { | ||||||
|  |       fields.remove("project_code"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     order.editForm( |     order.editForm( | ||||||
|       context, |       context, | ||||||
|       L10().purchaseOrderEdit, |       L10().purchaseOrderEdit, | ||||||
| @@ -202,6 +214,14 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg | |||||||
|  |  | ||||||
|     tiles.add(headerTile(context)); |     tiles.add(headerTile(context)); | ||||||
|  |  | ||||||
|  |     if (supportProjectCodes && order.hasProjectCode) { | ||||||
|  |       tiles.add(ListTile( | ||||||
|  |         title: Text(L10().projectCode), | ||||||
|  |         subtitle: Text("${order.projectCode} - ${order.projectCodeDescription}"), | ||||||
|  |         leading: FaIcon(FontAwesomeIcons.list), | ||||||
|  |       )); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     if (supplier != null) { |     if (supplier != null) { | ||||||
|       tiles.add(ListTile( |       tiles.add(ListTile( | ||||||
|         title: Text(L10().supplier), |         title: Text(L10().supplier), | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user