mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 18:25:26 +00:00
Project code support (#336)
* Determine if project codes are supported * Add helpers for boolean functions * Adds helper methods for generic "model" class - Will allow us to do some good refactoring * Refactor the refactor * Add debug support and getMap function * Major refactoring for model data accessors * Handle null values * Add sentry reporting if key is used incorrectly * Fix typo * Refactor createFromJson function * Add model for ProjectCode * Display and edit project code for purchase orders
This commit is contained in:
@ -43,6 +43,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
|
||||
int attachmentCount = 0;
|
||||
|
||||
bool supportProjectCodes = false;
|
||||
|
||||
@override
|
||||
String getAppBarTitle() => L10().purchaseOrder;
|
||||
|
||||
@ -139,6 +141,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
|
||||
lines = await order.getLineItems();
|
||||
|
||||
supportProjectCodes = api.supportsProjectCodes && await api.getGlobalBooleanSetting("PROJECT_CODES_ENABLED");
|
||||
|
||||
completedLines = 0;
|
||||
|
||||
for (var line in lines) {
|
||||
@ -157,12 +161,20 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
// Edit the currently displayed PurchaseOrder
|
||||
Future <void> editOrder(BuildContext context) async {
|
||||
var fields = order.formFields();
|
||||
|
||||
// Cannot edit supplier field from here
|
||||
fields.remove("supplier");
|
||||
|
||||
// Contact model not supported by server
|
||||
if (!api.supportsContactModel) {
|
||||
fields.remove("contact");
|
||||
}
|
||||
|
||||
// ProjectCode model not supported by server
|
||||
if (!supportProjectCodes) {
|
||||
fields.remove("project_code");
|
||||
}
|
||||
|
||||
order.editForm(
|
||||
context,
|
||||
L10().purchaseOrderEdit,
|
||||
@ -202,6 +214,14 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
|
||||
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) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplier),
|
||||
|
Reference in New Issue
Block a user