mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Adds attachment support for purchase orders
This commit is contained in:
parent
ada64f3971
commit
0237e9c819
@ -203,3 +203,24 @@ class InvenTreePOLineItem extends InvenTreeModel {
|
||||
return InvenTreePOLineItem.fromJson(json);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class representing an attachment file against a StockItem object
|
||||
*/
|
||||
class InvenTreePurchaseOrderAttachment extends InvenTreeAttachment {
|
||||
|
||||
InvenTreePurchaseOrderAttachment() : super();
|
||||
|
||||
InvenTreePurchaseOrderAttachment.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
||||
|
||||
@override
|
||||
String get REFERENCE_FIELD => "order";
|
||||
|
||||
@override
|
||||
String get URL => "order/po/attachment/";
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreePurchaseOrderAttachment.fromJson(json);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import "package:inventree/app_colors.dart";
|
||||
import "package:inventree/helpers.dart";
|
||||
import "package:inventree/inventree/company.dart";
|
||||
import "package:inventree/inventree/purchase_order.dart";
|
||||
import "package:inventree/widget/attachment_widget.dart";
|
||||
import "package:inventree/widget/company_detail.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
@ -37,6 +38,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
|
||||
int completedLines = 0;
|
||||
|
||||
int attachmentCount = 0;
|
||||
|
||||
String _poPrefix = "";
|
||||
|
||||
@override
|
||||
@ -77,6 +80,12 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
completedLines += 1;
|
||||
}
|
||||
}
|
||||
|
||||
attachmentCount = await InvenTreePurchaseOrderAttachment().count(
|
||||
filters: {
|
||||
"order": order.pk.toString()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Future <void> editOrder(BuildContext context) async {
|
||||
@ -177,6 +186,26 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
));
|
||||
}
|
||||
|
||||
// Attachments
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().attachments),
|
||||
leading: FaIcon(FontAwesomeIcons.fileAlt, color: COLOR_CLICK),
|
||||
trailing: attachmentCount > 0 ? Text(attachmentCount.toString()) : null,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AttachmentWidget(
|
||||
InvenTreePurchaseOrderAttachment(),
|
||||
order.pk,
|
||||
InvenTreeAPI().checkPermission("purchase_order", "change"))
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
return tiles;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user