mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Receive stock against purchase order line items
This commit is contained in:
parent
6ff99b15c3
commit
65180c7b2f
@ -1,5 +1,6 @@
|
|||||||
import "dart:async";
|
import "dart:async";
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import "package:intl/intl.dart";
|
import "package:intl/intl.dart";
|
||||||
import 'package:inventree/helpers.dart';
|
import 'package:inventree/helpers.dart';
|
||||||
import "package:inventree/inventree/part.dart";
|
import "package:inventree/inventree/part.dart";
|
||||||
@ -98,7 +99,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
Color get statusColor {
|
Color get statusColor {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case OK:
|
case OK:
|
||||||
return Color(0xFF50aa51);
|
return Colors.black;
|
||||||
case ATTENTION:
|
case ATTENTION:
|
||||||
return Color(0xFFfdc82a);
|
return Color(0xFFfdc82a);
|
||||||
case DAMAGED:
|
case DAMAGED:
|
||||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
|||||||
Subproject commit 603e0420a44996270e7cc29b278d8bdbf931e5c4
|
Subproject commit 74d796f7f1174fc27d5c031e18f4adbe1e16e6a4
|
@ -580,7 +580,10 @@ class _PaginatedStockListState extends State<PaginatedStockList> {
|
|||||||
height: 40,
|
height: 40,
|
||||||
),
|
),
|
||||||
trailing: Text("${item.displayQuantity}",
|
trailing: Text("${item.displayQuantity}",
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: item.statusColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_openItem(context, item.pk);
|
_openItem(context, item.pk);
|
||||||
|
@ -1,15 +1,25 @@
|
|||||||
|
import 'package:dropdown_search/dropdown_search.dart';
|
||||||
import "package:flutter/cupertino.dart";
|
import "package:flutter/cupertino.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||||
|
|
||||||
import "package:inventree/api.dart";
|
import "package:inventree/api.dart";
|
||||||
|
import 'package:inventree/api_form.dart';
|
||||||
import "package:inventree/app_colors.dart";
|
import "package:inventree/app_colors.dart";
|
||||||
|
import 'package:inventree/helpers.dart';
|
||||||
import "package:inventree/inventree/company.dart";
|
import "package:inventree/inventree/company.dart";
|
||||||
|
import 'package:inventree/inventree/model.dart';
|
||||||
|
import 'package:inventree/inventree/part.dart';
|
||||||
import "package:inventree/inventree/purchase_order.dart";
|
import "package:inventree/inventree/purchase_order.dart";
|
||||||
|
import 'package:inventree/inventree/stock.dart';
|
||||||
import "package:inventree/widget/company_detail.dart";
|
import "package:inventree/widget/company_detail.dart";
|
||||||
import "package:inventree/widget/refreshable_state.dart";
|
import "package:inventree/widget/refreshable_state.dart";
|
||||||
import "package:inventree/l10.dart";
|
import "package:inventree/l10.dart";
|
||||||
import "package:inventree/widget/location_display.dart";
|
import "package:inventree/widget/location_display.dart";
|
||||||
|
import 'package:inventree/widget/snacks.dart';
|
||||||
|
import 'package:one_context/one_context.dart';
|
||||||
|
|
||||||
|
import 'dialogs.dart';
|
||||||
|
|
||||||
|
|
||||||
class PurchaseOrderDetailWidget extends StatefulWidget {
|
class PurchaseOrderDetailWidget extends StatefulWidget {
|
||||||
@ -172,15 +182,70 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void receiveLine(BuildContext context, InvenTreePOLineItem lineItem) {
|
||||||
|
|
||||||
|
Map<String, dynamic> fields = {
|
||||||
|
"line_item": {
|
||||||
|
"parent": "items",
|
||||||
|
"nested": true,
|
||||||
|
"hidden": true,
|
||||||
|
"value": lineItem.pk,
|
||||||
|
},
|
||||||
|
"quantity": {
|
||||||
|
"parent": "items",
|
||||||
|
"nested": true,
|
||||||
|
"value": lineItem.outstanding,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"parent": "items",
|
||||||
|
"nested": true,
|
||||||
|
},
|
||||||
|
"location": {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: Pre-fill the "location" value if the part has a default location specified
|
||||||
|
|
||||||
|
launchApiForm(
|
||||||
|
context,
|
||||||
|
L10().receiveItem,
|
||||||
|
order.receive_url,
|
||||||
|
fields,
|
||||||
|
method: "POST",
|
||||||
|
icon: FontAwesomeIcons.signInAlt,
|
||||||
|
onSuccess: (data) async {
|
||||||
|
showSnackIcon(L10().receivedItem, success: true);
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void lineItemMenu(BuildContext context, InvenTreePOLineItem lineItem) {
|
void lineItemMenu(BuildContext context, InvenTreePOLineItem lineItem) {
|
||||||
|
|
||||||
List<Widget> children = [];
|
List<Widget> children = [];
|
||||||
|
|
||||||
if (InvenTreeAPI().supportPoReceive()) {
|
children.add(
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () {
|
||||||
|
OneContext().popDialog();
|
||||||
|
|
||||||
|
// TODO: Navigate to the "SupplierPart" display?
|
||||||
|
},
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(L10().viewSupplierPart),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.eye),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (order.isPlaced && InvenTreeAPI().supportPoReceive()) {
|
||||||
children.add(
|
children.add(
|
||||||
SimpleDialogOption(
|
SimpleDialogOption(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
// Hide the dialog option
|
||||||
|
OneContext().popDialog();
|
||||||
|
|
||||||
|
receiveLine(context, lineItem);
|
||||||
},
|
},
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
title: Text(L10().receiveItem),
|
title: Text(L10().receiveItem),
|
||||||
@ -219,15 +284,37 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
|||||||
|
|
||||||
InvenTreeSupplierPart? supplierPart = line.supplierPart;
|
InvenTreeSupplierPart? supplierPart = line.supplierPart;
|
||||||
|
|
||||||
if (supplierPart == null) {
|
if (supplierPart != null) {
|
||||||
continue;
|
|
||||||
} else {
|
String q = simpleNumberString(line.quantity);
|
||||||
|
|
||||||
|
Color c = Colors.black;
|
||||||
|
|
||||||
|
if (order.isOpen) {
|
||||||
|
|
||||||
|
q = simpleNumberString(line.received) + " / " + simpleNumberString(line.quantity);
|
||||||
|
|
||||||
|
if (line.isComplete) {
|
||||||
|
c = COLOR_SUCCESS;
|
||||||
|
} else {
|
||||||
|
c = COLOR_DANGER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(supplierPart.SKU),
|
title: Text(supplierPart.SKU),
|
||||||
subtitle: Text(supplierPart.partName),
|
subtitle: Text(supplierPart.partName),
|
||||||
leading: InvenTreeAPI().getImage(supplierPart.partImage, width: 40, height: 40),
|
leading: InvenTreeAPI().getImage(supplierPart.partImage, width: 40, height: 40),
|
||||||
trailing: Text("${line.outstanding}"),
|
trailing: Text(
|
||||||
|
q,
|
||||||
|
style: TextStyle(
|
||||||
|
color: c,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
// TODO: ?
|
||||||
|
},
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
lineItemMenu(context, line);
|
lineItemMenu(context, line);
|
||||||
},
|
},
|
||||||
|
@ -414,7 +414,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().quantity),
|
title: Text(L10().quantity),
|
||||||
leading: FaIcon(FontAwesomeIcons.cubes),
|
leading: FaIcon(FontAwesomeIcons.cubes),
|
||||||
trailing: Text("${item.quantityString}"),
|
trailing: Text("${item.quantityString()}"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user