mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-16 20:25:26 +00:00
Format code
This commit is contained in:
@ -18,12 +18,10 @@ import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/stock/stock_list.dart";
|
||||
import "package:inventree/labels.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying detail view for a single StockLocation instance
|
||||
*/
|
||||
class LocationDisplayWidget extends StatefulWidget {
|
||||
|
||||
LocationDisplayWidget(this.location, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeStockLocation? location;
|
||||
@ -35,7 +33,6 @@ class LocationDisplayWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
_LocationDisplayState(this.location);
|
||||
|
||||
final InvenTreeStockLocation? location;
|
||||
@ -53,31 +50,24 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
// Add "locate" button
|
||||
if (location != null && api.supportsMixin("locate")) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(Icons.travel_explore),
|
||||
tooltip: L10().locateLocation,
|
||||
onPressed: () async {
|
||||
api.locateItemOrLocation(context, location: location!.pk);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(Icons.travel_explore),
|
||||
tooltip: L10().locateLocation,
|
||||
onPressed: () async {
|
||||
api.locateItemOrLocation(context, location: location!.pk);
|
||||
}));
|
||||
}
|
||||
|
||||
// Add "edit" button
|
||||
if (location != null && InvenTreeStockLocation().canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editLocation,
|
||||
onPressed: () {
|
||||
_editLocationDialog(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editLocation,
|
||||
onPressed: () {
|
||||
_editLocationDialog(context);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@ -88,63 +78,50 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
if (location != null) {
|
||||
// Scan items into this location
|
||||
if (InvenTreeStockItem().canEdit) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.qrcode),
|
||||
label: L10().barcodeScanItem,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: StockLocationScanInItemsHandler(location!),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.qrcode),
|
||||
label: L10().barcodeScanItem,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: StockLocationScanInItemsHandler(location!),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
if (api.supportsBarcodePOReceiveEndpoint) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap:() async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(location: location),
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(Icons.barcode_reader),
|
||||
label: L10().scanReceivedParts,
|
||||
onTap: () async {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: POReceiveBarcodeHandler(location: location),
|
||||
);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Scan this location into another one
|
||||
if (InvenTreeStockLocation().canEdit) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.qrcode),
|
||||
label: L10().transferStockLocation,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: ScanParentLocationHandler(location!),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.qrcode),
|
||||
label: L10().transferStockLocation,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: ScanParentLocationHandler(location!),
|
||||
).then((value) {
|
||||
refresh(context);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
// Assign or un-assign barcodes
|
||||
actions.add(
|
||||
customBarcodeAction(
|
||||
context, this,
|
||||
location!.customBarcode, "stocklocation",
|
||||
location!.pk
|
||||
)
|
||||
);
|
||||
actions.add(customBarcodeAction(context, this, location!.customBarcode,
|
||||
"stocklocation", location!.pk));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -156,46 +133,32 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
// Create new location
|
||||
if (InvenTreeStockLocation().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.sitemap),
|
||||
label: L10().locationCreate,
|
||||
onTap: () async {
|
||||
_newLocation(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.sitemap),
|
||||
label: L10().locationCreate,
|
||||
onTap: () async {
|
||||
_newLocation(context);
|
||||
}));
|
||||
}
|
||||
|
||||
// Create new item
|
||||
if (InvenTreeStockItem().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.packages),
|
||||
label: L10().stockItemCreate,
|
||||
onTap: () async {
|
||||
_newStockItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.packages),
|
||||
label: L10().stockItemCreate,
|
||||
onTap: () async {
|
||||
_newStockItem(context);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.location != null && labels.isNotEmpty) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.printer),
|
||||
label: L10().printLabel,
|
||||
onTap: () async {
|
||||
selectAndPrintLabel(
|
||||
context,
|
||||
labels,
|
||||
widget.location!.pk,
|
||||
"location",
|
||||
"location=${widget.location!.pk}"
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.printer),
|
||||
label: L10().printLabel,
|
||||
onTap: () async {
|
||||
selectAndPrintLabel(context, labels, widget.location!.pk,
|
||||
"location", "location=${widget.location!.pk}");
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -211,14 +174,10 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
return;
|
||||
}
|
||||
|
||||
_loc.editForm(
|
||||
context,
|
||||
L10().editLocation,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().locationUpdated, success: true);
|
||||
}
|
||||
);
|
||||
_loc.editForm(context, L10().editLocation, onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().locationUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -238,22 +197,20 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> _labels = [];
|
||||
bool allowLabelPrinting = await InvenTreeSettingsManager().getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
bool allowLabelPrinting = await InvenTreeSettingsManager()
|
||||
.getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
allowLabelPrinting &= api.supportsMixin("labels");
|
||||
|
||||
if (allowLabelPrinting) {
|
||||
|
||||
if (widget.location != null) {
|
||||
|
||||
String model_type = api.supportsModernLabelPrinting ? InvenTreeStockLocation.MODEL_TYPE : "location";
|
||||
String item_key = api.supportsModernLabelPrinting ? "items" : "location";
|
||||
String model_type = api.supportsModernLabelPrinting
|
||||
? InvenTreeStockLocation.MODEL_TYPE
|
||||
: "location";
|
||||
String item_key =
|
||||
api.supportsModernLabelPrinting ? "items" : "location";
|
||||
|
||||
_labels = await getLabelTemplates(
|
||||
model_type,
|
||||
{
|
||||
item_key: widget.location!.pk.toString()
|
||||
}
|
||||
);
|
||||
model_type, {item_key: widget.location!.pk.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,28 +224,22 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
Future<void> _newLocation(BuildContext context) async {
|
||||
int pk = location?.pk ?? -1;
|
||||
|
||||
InvenTreeStockLocation().createForm(
|
||||
context,
|
||||
L10().locationCreate,
|
||||
data: {
|
||||
"parent": (pk > 0) ? pk : null,
|
||||
},
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
InvenTreeStockLocation().createForm(context, L10().locationCreate, data: {
|
||||
"parent": (pk > 0) ? pk : null,
|
||||
}, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var loc = InvenTreeStockLocation.fromJson(data);
|
||||
loc.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (data.containsKey("pk")) {
|
||||
var loc = InvenTreeStockLocation.fromJson(data);
|
||||
loc.goToDetailPage(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Launch a dialog form to create a new stock item
|
||||
*/
|
||||
Future<void> _newStockItem(BuildContext context) async {
|
||||
|
||||
var fields = InvenTreeStockItem().formFields();
|
||||
|
||||
// Serial number field is not required here
|
||||
@ -300,73 +251,65 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
data["location"] = location!.pk;
|
||||
}
|
||||
|
||||
InvenTreeStockItem().createForm(
|
||||
context,
|
||||
L10().stockItemCreate,
|
||||
data: data,
|
||||
fields: fields,
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
InvenTreeStockItem().createForm(context, L10().stockItemCreate,
|
||||
data: data, fields: fields, onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var item = InvenTreeStockItem.fromJson(data);
|
||||
item.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (data.containsKey("pk")) {
|
||||
var item = InvenTreeStockItem.fromJson(data);
|
||||
item.goToDetailPage(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget locationDescriptionCard({bool includeActions = true}) {
|
||||
if (location == null) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
L10().stockTopLevel,
|
||||
style: TextStyle(fontStyle: FontStyle.italic)
|
||||
),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
)
|
||||
);
|
||||
title: Text(L10().stockTopLevel,
|
||||
style: TextStyle(fontStyle: FontStyle.italic)),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
));
|
||||
} else {
|
||||
List<Widget> children = [
|
||||
ListTile(
|
||||
title: Text("${location!.name}"),
|
||||
subtitle: Text("${location!.description}"),
|
||||
leading: location!.customIcon == null ? Icon(TablerIcons.packages) : Icon(location!.customIcon)
|
||||
),
|
||||
title: Text("${location!.name}"),
|
||||
subtitle: Text("${location!.description}"),
|
||||
leading: location!.customIcon == null
|
||||
? Icon(TablerIcons.packages)
|
||||
: Icon(location!.customIcon)),
|
||||
];
|
||||
|
||||
if (includeActions) {
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(L10().parentLocation),
|
||||
subtitle: Text("${location!.parentPathString}"),
|
||||
leading: Icon(TablerIcons.arrow_move_up, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
int parentId = location?.parentId ?? -1;
|
||||
children.add(ListTile(
|
||||
title: Text(L10().parentLocation),
|
||||
subtitle: Text("${location!.parentPathString}"),
|
||||
leading: Icon(TablerIcons.arrow_move_up, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
int parentId = location?.parentId ?? -1;
|
||||
|
||||
if (parentId < 0) {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
if (parentId < 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LocationDisplayWidget(null)));
|
||||
} else {
|
||||
showLoadingOverlay();
|
||||
var loc = await InvenTreeStockLocation().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
} else {
|
||||
showLoadingOverlay();
|
||||
var loc = await InvenTreeStockLocation().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (loc is InvenTreeStockLocation) {
|
||||
loc.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
if (loc is InvenTreeStockLocation) {
|
||||
loc.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return Card(
|
||||
child: Column(
|
||||
children: children,
|
||||
)
|
||||
);
|
||||
children: children,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,7 +331,6 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
|
||||
// Construct the "details" panel
|
||||
List<Widget> detailTiles() {
|
||||
|
||||
Map<String, String> filters = {};
|
||||
|
||||
int? parent = location?.pk;
|
||||
|
@ -7,9 +7,7 @@ import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
|
||||
class StockLocationList extends StatefulWidget {
|
||||
|
||||
const StockLocationList(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
@ -18,9 +16,7 @@ class StockLocationList extends StatefulWidget {
|
||||
_StockLocationListState createState() => _StockLocationListState(filters);
|
||||
}
|
||||
|
||||
|
||||
class _StockLocationListState extends RefreshableState<StockLocationList> {
|
||||
|
||||
_StockLocationListState(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
@ -34,50 +30,50 @@ class _StockLocationListState extends RefreshableState<StockLocationList> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PaginatedStockLocationList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedStockLocationList(Map<String, String> filters, {String title = ""}) : super(filters: filters, title: title);
|
||||
const PaginatedStockLocationList(Map<String, String> filters,
|
||||
{String title = ""})
|
||||
: super(filters: filters, title: title);
|
||||
|
||||
@override
|
||||
String get searchTitle => title.isNotEmpty ? title : L10().stockLocations;
|
||||
|
||||
@override
|
||||
_PaginatedStockLocationListState createState() => _PaginatedStockLocationListState();
|
||||
_PaginatedStockLocationListState createState() =>
|
||||
_PaginatedStockLocationListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedStockLocationListState extends PaginatedSearchState<PaginatedStockLocationList> {
|
||||
|
||||
class _PaginatedStockLocationListState
|
||||
extends PaginatedSearchState<PaginatedStockLocationList> {
|
||||
_PaginatedStockLocationListState() : super();
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"name": L10().name,
|
||||
"items": L10().stockItems,
|
||||
"level": L10().level,
|
||||
};
|
||||
"name": L10().name,
|
||||
"items": L10().stockItems,
|
||||
"level": L10().level,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions => {
|
||||
"cascade": {
|
||||
"label": L10().includeSublocations,
|
||||
"help_text": L10().includeSublocationsDetail,
|
||||
"tristate": false,
|
||||
}
|
||||
};
|
||||
"cascade": {
|
||||
"label": L10().includeSublocations,
|
||||
"help_text": L10().includeSublocationsDetail,
|
||||
"tristate": false,
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreeStockLocation().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
final page = await InvenTreeStockLocation()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeStockLocation location = model as InvenTreeStockLocation;
|
||||
|
||||
return ListTile(
|
||||
@ -90,4 +86,4 @@ class _PaginatedStockLocationListState extends PaginatedSearchState<PaginatedSto
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,7 @@ import "package:inventree/widget/stock/stock_item_history.dart";
|
||||
import "package:inventree/widget/stock/stock_item_test_results.dart";
|
||||
import "package:inventree/widget/notes_widget.dart";
|
||||
|
||||
|
||||
class StockDetailWidget extends StatefulWidget {
|
||||
|
||||
const StockDetailWidget(this.item, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeStockItem item;
|
||||
@ -39,9 +37,7 @@ class StockDetailWidget extends StatefulWidget {
|
||||
_StockItemDisplayState createState() => _StockItemDisplayState();
|
||||
}
|
||||
|
||||
|
||||
class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
_StockItemDisplayState();
|
||||
|
||||
@override
|
||||
@ -61,27 +57,21 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
List<Widget> actions = [];
|
||||
|
||||
if (api.supportsMixin("locate")) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(Icons.travel_explore),
|
||||
tooltip: L10().locateItem,
|
||||
onPressed: () async {
|
||||
api.locateItemOrLocation(context, item: widget.item.pk);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(Icons.travel_explore),
|
||||
tooltip: L10().locateItem,
|
||||
onPressed: () async {
|
||||
api.locateItemOrLocation(context, item: widget.item.pk);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editItem,
|
||||
onPressed: () {
|
||||
_editStockItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editItem,
|
||||
onPressed: () {
|
||||
_editStockItem(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -89,79 +79,56 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
@override
|
||||
List<SpeedDialChild> actionButtons(BuildContext context) {
|
||||
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (widget.item.canEdit) {
|
||||
|
||||
// Stock adjustment actions available if item is *not* serialized
|
||||
if (!widget.item.isSerialized()) {
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_check, color: Colors.blue),
|
||||
label: L10().countStock,
|
||||
onTap: _countStockDialog,
|
||||
));
|
||||
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_check, color: Colors.blue),
|
||||
label: L10().countStock,
|
||||
onTap: _countStockDialog,
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_minus, color: Colors.red),
|
||||
label: L10().removeStock,
|
||||
onTap: _removeStockDialog,
|
||||
));
|
||||
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_minus, color: Colors.red),
|
||||
label: L10().removeStock,
|
||||
onTap: _removeStockDialog,
|
||||
)
|
||||
);
|
||||
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().addStock,
|
||||
onTap: _addStockDialog,
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().addStock,
|
||||
onTap: _addStockDialog,
|
||||
));
|
||||
}
|
||||
|
||||
// Transfer item
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.transfer),
|
||||
label: L10().transferStock,
|
||||
onTap: () {
|
||||
_transferStockDialog(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
if (labels.isNotEmpty) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.printer),
|
||||
label: L10().printLabel,
|
||||
onTap: () async {
|
||||
selectAndPrintLabel(
|
||||
context,
|
||||
labels,
|
||||
widget.item.pk,
|
||||
"stock",
|
||||
"item=${widget.item.pk}"
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
selectAndPrintLabel(context, labels, widget.item.pk, "stock",
|
||||
"item=${widget.item.pk}");
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.canDelete) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.trash, color: Colors.red),
|
||||
label: L10().stockItemDelete,
|
||||
onTap: () {
|
||||
_deleteItem(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.trash, color: Colors.red),
|
||||
label: L10().stockItemDelete,
|
||||
onTap: () {
|
||||
_deleteItem(context);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -173,28 +140,19 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
if (widget.item.canEdit) {
|
||||
// Scan item into location
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.qr_code_scanner),
|
||||
label: L10().scanIntoLocation,
|
||||
onTap: () {
|
||||
scanBarcode(
|
||||
context,
|
||||
handler: StockItemScanIntoLocationHandler(widget.item)
|
||||
).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(Icons.qr_code_scanner),
|
||||
label: L10().scanIntoLocation,
|
||||
onTap: () {
|
||||
scanBarcode(context,
|
||||
handler: StockItemScanIntoLocationHandler(widget.item))
|
||||
.then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
}));
|
||||
|
||||
actions.add(
|
||||
customBarcodeAction(
|
||||
context, this,
|
||||
widget.item.customBarcode,
|
||||
"stockitem", widget.item.pk
|
||||
)
|
||||
);
|
||||
actions.add(customBarcodeAction(context, this, widget.item.customBarcode,
|
||||
"stockitem", widget.item.pk));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -217,8 +175,10 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
await api.StockStatus.load();
|
||||
stockShowHistory = await InvenTreeSettingsManager().getValue(INV_STOCK_SHOW_HISTORY, false) as bool;
|
||||
stockShowTests = await InvenTreeSettingsManager().getValue(INV_STOCK_SHOW_TESTS, true) as bool;
|
||||
stockShowHistory = await InvenTreeSettingsManager()
|
||||
.getValue(INV_STOCK_SHOW_HISTORY, false) as bool;
|
||||
stockShowTests = await InvenTreeSettingsManager()
|
||||
.getValue(INV_STOCK_SHOW_TESTS, true) as bool;
|
||||
|
||||
final bool result = widget.item.pk > 0 && await widget.item.reload();
|
||||
|
||||
@ -238,7 +198,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
// Request test results (async)
|
||||
if (stockShowTests) {
|
||||
widget.item.getTestResults().then((value) {
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
// Update
|
||||
@ -248,7 +207,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
}
|
||||
|
||||
// Request the number of attachments
|
||||
InvenTreeStockItemAttachment().countAttachments(widget.item.pk).then((int value) {
|
||||
InvenTreeStockItemAttachment()
|
||||
.countAttachments(widget.item.pk)
|
||||
.then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
@ -259,12 +220,13 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
// Request SalesOrder information
|
||||
if (widget.item.hasSalesOrder) {
|
||||
InvenTreeSalesOrder().get(widget.item.salesOrderId).then((instance) => {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
salesOrder = instance as InvenTreeSalesOrder?;
|
||||
})
|
||||
}
|
||||
});
|
||||
if (mounted)
|
||||
{
|
||||
setState(() {
|
||||
salesOrder = instance as InvenTreeSalesOrder?;
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -276,12 +238,13 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
// Request Customer information
|
||||
if (widget.item.hasCustomer) {
|
||||
InvenTreeCompany().get(widget.item.customerId).then((instance) => {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
customer = instance as InvenTreeCompany?;
|
||||
})
|
||||
}
|
||||
});
|
||||
if (mounted)
|
||||
{
|
||||
setState(() {
|
||||
customer = instance as InvenTreeCompany?;
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -291,22 +254,20 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> _labels = [];
|
||||
bool allowLabelPrinting = await InvenTreeSettingsManager().getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
bool allowLabelPrinting = await InvenTreeSettingsManager()
|
||||
.getBool(INV_ENABLE_LABEL_PRINTING, true);
|
||||
allowLabelPrinting &= api.supportsMixin("labels");
|
||||
|
||||
// Request information on labels available for this stock item
|
||||
if (allowLabelPrinting) {
|
||||
|
||||
String model_type = api.supportsModernLabelPrinting ? InvenTreeStockItem.MODEL_TYPE : "stock";
|
||||
String model_type = api.supportsModernLabelPrinting
|
||||
? InvenTreeStockItem.MODEL_TYPE
|
||||
: "stock";
|
||||
String item_key = api.supportsModernLabelPrinting ? "items" : "item";
|
||||
|
||||
// Clear the existing labels list
|
||||
_labels = await getLabelTemplates(
|
||||
model_type,
|
||||
{
|
||||
item_key: widget.item.pk.toString()
|
||||
}
|
||||
);
|
||||
model_type, {item_key: widget.item.pk.toString()});
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
@ -318,7 +279,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
/// Delete the stock item from the database
|
||||
Future<void> _deleteItem(BuildContext context) async {
|
||||
|
||||
confirmationDialog(
|
||||
L10().stockItemDelete,
|
||||
L10().stockItemDeleteConfirm,
|
||||
@ -327,7 +287,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
acceptText: L10().delete,
|
||||
onAccept: () async {
|
||||
final bool result = await widget.item.delete();
|
||||
|
||||
|
||||
if (result) {
|
||||
Navigator.of(context).pop();
|
||||
showSnackIcon(L10().stockItemDeleteSuccess, success: true);
|
||||
@ -336,11 +296,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
Future <void> _editStockItem(BuildContext context) async {
|
||||
|
||||
Future<void> _editStockItem(BuildContext context) async {
|
||||
var fields = InvenTreeStockItem().formFields();
|
||||
|
||||
// Some fields we don't want to edit!
|
||||
@ -353,23 +311,17 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
fields.remove("serial");
|
||||
}
|
||||
|
||||
widget.item.editForm(
|
||||
context,
|
||||
L10().editItem,
|
||||
fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().stockItemUpdated, success: true);
|
||||
}
|
||||
);
|
||||
|
||||
widget.item.editForm(context, L10().editItem, fields: fields,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().stockItemUpdated, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Launch a dialog to 'add' quantity to this StockItem
|
||||
*/
|
||||
Future <void> _addStockDialog() async {
|
||||
|
||||
Future<void> _addStockDialog() async {
|
||||
Map<String, dynamic> fields = {
|
||||
"pk": {
|
||||
"parent": "items",
|
||||
@ -386,21 +338,14 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
};
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().addStock,
|
||||
InvenTreeStockItem.addStockUrl(),
|
||||
fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.circle_plus,
|
||||
onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
context, L10().addStock, InvenTreeStockItem.addStockUrl(), fields,
|
||||
method: "POST", icon: TablerIcons.circle_plus, onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
void _stockUpdateMessage(bool result) {
|
||||
|
||||
if (result) {
|
||||
showSnackIcon(L10().stockItemUpdated, success: true);
|
||||
}
|
||||
@ -410,7 +355,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
* Launch a dialog to 'remove' quantity from this StockItem
|
||||
*/
|
||||
void _removeStockDialog() {
|
||||
|
||||
Map<String, dynamic> fields = {
|
||||
"pk": {
|
||||
"parent": "items",
|
||||
@ -427,21 +371,15 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
};
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().removeStock,
|
||||
InvenTreeStockItem.removeStockUrl(),
|
||||
fields,
|
||||
context, L10().removeStock, InvenTreeStockItem.removeStockUrl(), fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.circle_minus,
|
||||
onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
icon: TablerIcons.circle_minus, onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> _countStockDialog() async {
|
||||
|
||||
Future<void> _countStockDialog() async {
|
||||
Map<String, dynamic> fields = {
|
||||
"pk": {
|
||||
"parent": "items",
|
||||
@ -458,82 +396,60 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
};
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().countStock,
|
||||
InvenTreeStockItem.countStockUrl(),
|
||||
fields,
|
||||
context, L10().countStock, InvenTreeStockItem.countStockUrl(), fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.clipboard_check,
|
||||
onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
icon: TablerIcons.clipboard_check, onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Launches an API Form to transfer this stock item to a new location
|
||||
*/
|
||||
Future <void> _transferStockDialog(BuildContext context) async {
|
||||
|
||||
Future<void> _transferStockDialog(BuildContext context) async {
|
||||
Map<String, dynamic> fields = widget.item.transferFields();
|
||||
|
||||
launchApiForm(
|
||||
context,
|
||||
L10().transferStock,
|
||||
InvenTreeStockItem.transferStockUrl(),
|
||||
fields,
|
||||
method: "POST",
|
||||
icon: TablerIcons.transfer,
|
||||
onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
}
|
||||
);
|
||||
launchApiForm(context, L10().transferStock,
|
||||
InvenTreeStockItem.transferStockUrl(), fields,
|
||||
method: "POST", icon: TablerIcons.transfer, onSuccess: (data) async {
|
||||
_stockUpdateMessage(true);
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
|
||||
Widget headerTile() {
|
||||
|
||||
Widget? trailing;
|
||||
|
||||
if (!widget.item.isInStock) {
|
||||
trailing = Text(
|
||||
L10().unavailable,
|
||||
style: TextStyle(
|
||||
color: COLOR_DANGER
|
||||
)
|
||||
);
|
||||
trailing = Text(L10().unavailable, style: TextStyle(color: COLOR_DANGER));
|
||||
} else if (!widget.item.isSerialized()) {
|
||||
trailing = Text(
|
||||
widget.item.quantityString(),
|
||||
trailing = Text(widget.item.quantityString(),
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: api.StockStatus.color(widget.item.status),
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(widget.item.partName),
|
||||
subtitle: Text(widget.item.partDescription),
|
||||
leading: InvenTreeAPI().getThumbnail(widget.item.partImage),
|
||||
trailing: trailing,
|
||||
onTap: () async {
|
||||
if (widget.item.partId > 0) {
|
||||
child: ListTile(
|
||||
title: Text(widget.item.partName),
|
||||
subtitle: Text(widget.item.partDescription),
|
||||
leading: InvenTreeAPI().getThumbnail(widget.item.partImage),
|
||||
trailing: trailing,
|
||||
onTap: () async {
|
||||
if (widget.item.partId > 0) {
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(widget.item.partId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(widget.item.partId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
//trailing: Text(item.serialOrQuantityDisplay()),
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
//trailing: Text(item.serialOrQuantityDisplay()),
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -564,9 +480,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
),
|
||||
onTap: () async {
|
||||
if (widget.item.locationId > 0) {
|
||||
|
||||
showLoadingOverlay();
|
||||
var loc = await InvenTreeStockLocation().get(widget.item.locationId);
|
||||
var loc =
|
||||
await InvenTreeStockLocation().get(widget.item.locationId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (loc is InvenTreeStockLocation) {
|
||||
@ -577,37 +493,32 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().stockLocation),
|
||||
leading: Icon(TablerIcons.location),
|
||||
subtitle: Text(L10().locationNotSet),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().stockLocation),
|
||||
leading: Icon(TablerIcons.location),
|
||||
subtitle: Text(L10().locationNotSet),
|
||||
));
|
||||
}
|
||||
|
||||
// Quantity information
|
||||
if (widget.item.isSerialized()) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().serialNumber),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
subtitle: Text("${widget.item.serialNumber}"),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().serialNumber),
|
||||
leading: Icon(TablerIcons.hash),
|
||||
subtitle: Text("${widget.item.serialNumber}"),
|
||||
));
|
||||
} else if (widget.item.isInStock) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: widget.item.allocated > 0 ? Text(L10().quantityAvailable) : Text(L10().quantity),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
trailing: Text("${widget.item.quantityString()}"),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: widget.item.allocated > 0
|
||||
? Text(L10().quantityAvailable)
|
||||
: Text(L10().quantity),
|
||||
leading: Icon(TablerIcons.packages),
|
||||
trailing: Text("${widget.item.quantityString()}"),
|
||||
));
|
||||
}
|
||||
|
||||
if (!widget.item.isInStock) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
leading: Icon(TablerIcons.box_off),
|
||||
title: Text(
|
||||
L10().unavailable,
|
||||
@ -616,258 +527,207 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
L10().unavailableDetail,
|
||||
style: TextStyle(
|
||||
color: COLOR_DANGER
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
subtitle: Text(L10().unavailableDetail,
|
||||
style: TextStyle(color: COLOR_DANGER))));
|
||||
}
|
||||
|
||||
// Stock item status information
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().status),
|
||||
leading: Icon(TablerIcons.help_circle),
|
||||
trailing: Text(
|
||||
api.StockStatus.label(widget.item.status),
|
||||
style: TextStyle(
|
||||
color: api.StockStatus.color(widget.item.status),
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(api.StockStatus.label(widget.item.status),
|
||||
style: TextStyle(
|
||||
color: api.StockStatus.color(widget.item.status),
|
||||
))));
|
||||
|
||||
// Supplier part information (if available)
|
||||
if (widget.item.supplierPartId > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplierPart),
|
||||
subtitle: Text(widget.item.supplierSKU),
|
||||
leading: Icon(TablerIcons.building, color: COLOR_ACTION),
|
||||
trailing: InvenTreeAPI().getThumbnail(widget.item.supplierImage, hideIfNull: true),
|
||||
trailing: InvenTreeAPI()
|
||||
.getThumbnail(widget.item.supplierImage, hideIfNull: true),
|
||||
onTap: () async {
|
||||
showLoadingOverlay();
|
||||
var sp = await InvenTreeSupplierPart().get(
|
||||
widget.item.supplierPartId);
|
||||
var sp =
|
||||
await InvenTreeSupplierPart().get(widget.item.supplierPartId);
|
||||
hideLoadingOverlay();
|
||||
if (sp is InvenTreeSupplierPart) {
|
||||
Navigator.push(
|
||||
context, MaterialPageRoute(
|
||||
builder: (context) => SupplierPartDetailWidget(sp))
|
||||
);
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SupplierPartDetailWidget(sp)));
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.isBuilding) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().inProduction),
|
||||
leading: Icon(TablerIcons.tools),
|
||||
subtitle: Text(L10().inProductionDetail),
|
||||
onTap: () {
|
||||
// TODO: Click through to the "build order"
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().inProduction),
|
||||
leading: Icon(TablerIcons.tools),
|
||||
subtitle: Text(L10().inProductionDetail),
|
||||
onTap: () {
|
||||
// TODO: Click through to the "build order"
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.item.hasSalesOrder && salesOrder != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().salesOrder),
|
||||
subtitle: Text(salesOrder?.description ?? ""),
|
||||
leading: Icon(TablerIcons.truck_delivery, color: COLOR_ACTION),
|
||||
trailing: Text(salesOrder?.reference ?? ""),
|
||||
onTap: () {
|
||||
salesOrder?.goToDetailPage(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.hasCustomer && customer != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().customer),
|
||||
subtitle: Text(customer?.description ?? ""),
|
||||
leading: Icon(TablerIcons.building_store, color: COLOR_ACTION),
|
||||
trailing: Text(customer?.name ?? ""),
|
||||
onTap: () {
|
||||
customer?.goToDetailPage(context);
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().customer),
|
||||
subtitle: Text(customer?.description ?? ""),
|
||||
leading: Icon(TablerIcons.building_store, color: COLOR_ACTION),
|
||||
trailing: Text(customer?.name ?? ""),
|
||||
onTap: () {
|
||||
customer?.goToDetailPage(context);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.item.batch.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().batchCode),
|
||||
subtitle: Text(widget.item.batch),
|
||||
leading: Icon(TablerIcons.clipboard_text),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().batchCode),
|
||||
subtitle: Text(widget.item.batch),
|
||||
leading: Icon(TablerIcons.clipboard_text),
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.item.packaging.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().packaging),
|
||||
subtitle: Text(widget.item.packaging),
|
||||
leading: Icon(TablerIcons.package),
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().packaging),
|
||||
subtitle: Text(widget.item.packaging),
|
||||
leading: Icon(TablerIcons.package),
|
||||
));
|
||||
}
|
||||
|
||||
if (expiryEnabled && widget.item.expiryDate != null) {
|
||||
|
||||
Widget? _expiryIcon;
|
||||
|
||||
if (widget.item.expired) {
|
||||
_expiryIcon = Text(L10().expiryExpired, style: TextStyle(color: COLOR_DANGER));
|
||||
_expiryIcon =
|
||||
Text(L10().expiryExpired, style: TextStyle(color: COLOR_DANGER));
|
||||
} else if (widget.item.stale) {
|
||||
_expiryIcon = Text(L10().expiryStale, style: TextStyle(color: COLOR_WARNING));
|
||||
_expiryIcon =
|
||||
Text(L10().expiryStale, style: TextStyle(color: COLOR_WARNING));
|
||||
}
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().expiryDate),
|
||||
subtitle: Text(widget.item.expiryDateString),
|
||||
leading: Icon(TablerIcons.calendar_x),
|
||||
trailing: _expiryIcon,
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().expiryDate),
|
||||
subtitle: Text(widget.item.expiryDateString),
|
||||
leading: Icon(TablerIcons.calendar_x),
|
||||
trailing: _expiryIcon,
|
||||
));
|
||||
}
|
||||
|
||||
// Last update?
|
||||
if (widget.item.updatedDateString.isNotEmpty) {
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().lastUpdated),
|
||||
subtitle: Text(widget.item.updatedDateString),
|
||||
leading: Icon(TablerIcons.calendar)
|
||||
)
|
||||
);
|
||||
leading: Icon(TablerIcons.calendar)));
|
||||
}
|
||||
|
||||
// Stocktake?
|
||||
if (widget.item.stocktakeDateString.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().lastStocktake),
|
||||
subtitle: Text(widget.item.stocktakeDateString),
|
||||
leading: Icon(TablerIcons.calendar)
|
||||
)
|
||||
);
|
||||
leading: Icon(TablerIcons.calendar)));
|
||||
}
|
||||
|
||||
if (widget.item.link.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${widget.item.link}"),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
widget.item.openLink();
|
||||
},
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text("${widget.item.link}"),
|
||||
leading: Icon(TablerIcons.link, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
widget.item.openLink();
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if (stockShowTests || (widget.item.testResultCount > 0)) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().testResults),
|
||||
leading: Icon(TablerIcons.list_check, color: COLOR_ACTION),
|
||||
trailing: Text("${widget.item.testResultCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StockItemTestResultsWidget(widget.item))
|
||||
).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().testResults),
|
||||
leading: Icon(TablerIcons.list_check, color: COLOR_ACTION),
|
||||
trailing: Text("${widget.item.testResultCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
StockItemTestResultsWidget(widget.item))).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
if (widget.item.hasPurchasePrice) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().purchasePrice),
|
||||
leading: Icon(TablerIcons.currency_dollar),
|
||||
trailing: Text(
|
||||
renderCurrency(widget.item.purchasePrice, widget.item.purchasePriceCurrency)
|
||||
)
|
||||
)
|
||||
);
|
||||
trailing: Text(renderCurrency(
|
||||
widget.item.purchasePrice, widget.item.purchasePriceCurrency))));
|
||||
}
|
||||
|
||||
// TODO - Is this stock item linked to a PurchaseOrder?
|
||||
|
||||
if (stockShowHistory && widget.item.trackingItemCount > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().history),
|
||||
leading: Icon(TablerIcons.history, color: COLOR_ACTION),
|
||||
trailing: Text("${widget.item.trackingItemCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().history),
|
||||
leading: Icon(TablerIcons.history, color: COLOR_ACTION),
|
||||
trailing: Text("${widget.item.trackingItemCount}"),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StockItemHistoryWidget(widget.item))
|
||||
).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
},
|
||||
)
|
||||
);
|
||||
builder: (context) =>
|
||||
StockItemHistoryWidget(widget.item))).then((ctx) {
|
||||
refresh(context);
|
||||
});
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Notes field
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().notes),
|
||||
leading: Icon(TablerIcons.note, color: COLOR_ACTION),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => NotesWidget(widget.item))
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().attachments),
|
||||
leading: Icon(TablerIcons.file, color: COLOR_ACTION),
|
||||
trailing: attachmentCount > 0 ? Text(attachmentCount.toString()) : null,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => NotesWidget(widget.item)));
|
||||
}));
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().attachments),
|
||||
leading: Icon(TablerIcons.file, color: COLOR_ACTION),
|
||||
trailing: attachmentCount > 0 ? Text(attachmentCount.toString()) : null,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AttachmentWidget(
|
||||
InvenTreeStockItemAttachment(),
|
||||
widget.item.pk,
|
||||
L10().stockItem,
|
||||
widget.item.canEdit,
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
InvenTreeStockItemAttachment(),
|
||||
widget.item.pk,
|
||||
L10().stockItem,
|
||||
widget.item.canEdit,
|
||||
)));
|
||||
},
|
||||
));
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ class StockItemHistoryWidget extends StatefulWidget {
|
||||
final InvenTreeStockItem item;
|
||||
|
||||
@override
|
||||
_StockItemHistoryDisplayState createState() => _StockItemHistoryDisplayState(item);
|
||||
_StockItemHistoryDisplayState createState() =>
|
||||
_StockItemHistoryDisplayState(item);
|
||||
}
|
||||
|
||||
class _StockItemHistoryDisplayState extends RefreshableState<StockItemHistoryWidget> {
|
||||
class _StockItemHistoryDisplayState
|
||||
extends RefreshableState<StockItemHistoryWidget> {
|
||||
_StockItemHistoryDisplayState(this.item);
|
||||
|
||||
final InvenTreeStockItem item;
|
||||
@ -36,14 +38,14 @@ class _StockItemHistoryDisplayState extends RefreshableState<StockItemHistoryWid
|
||||
|
||||
return PaginatedStockHistoryList(filters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Widget which displays a paginated stock history list
|
||||
*/
|
||||
class PaginatedStockHistoryList extends PaginatedSearchWidget {
|
||||
const PaginatedStockHistoryList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedStockHistoryList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().stockItemHistory;
|
||||
@ -75,7 +77,8 @@ class _PaginatedStockHistoryState
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
await InvenTreeAPI().StockHistoryStatus.load();
|
||||
|
||||
final page = await InvenTreeStockItemHistory().listPaginated(limit, offset, filters: params);
|
||||
final page = await InvenTreeStockItemHistory()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
@ -13,20 +13,18 @@ import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
class StockItemTestResultsWidget extends StatefulWidget {
|
||||
|
||||
const StockItemTestResultsWidget(this.item, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreeStockItem item;
|
||||
|
||||
@override
|
||||
_StockItemTestResultDisplayState createState() => _StockItemTestResultDisplayState(item);
|
||||
_StockItemTestResultDisplayState createState() =>
|
||||
_StockItemTestResultDisplayState(item);
|
||||
}
|
||||
|
||||
|
||||
class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestResultsWidget> {
|
||||
|
||||
class _StockItemTestResultDisplayState
|
||||
extends RefreshableState<StockItemTestResultsWidget> {
|
||||
_StockItemTestResultDisplayState(this.item);
|
||||
|
||||
@override
|
||||
@ -40,15 +38,12 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreeStockItemTestResult().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
actions.add(SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus),
|
||||
label: L10().testResultAdd,
|
||||
onTap: () {
|
||||
addTestResult(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return actions;
|
||||
@ -62,9 +57,16 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
|
||||
final InvenTreeStockItem item;
|
||||
|
||||
Future <void> addTestResult(BuildContext context, {int templateId = 0, String name = "", bool nameIsEditable = true, bool result = false, String value = "", bool valueRequired = false, bool attachmentRequired = false}) async {
|
||||
|
||||
Map<String, Map<String, dynamic>> fields = InvenTreeStockItemTestResult().formFields();
|
||||
Future<void> addTestResult(BuildContext context,
|
||||
{int templateId = 0,
|
||||
String name = "",
|
||||
bool nameIsEditable = true,
|
||||
bool result = false,
|
||||
String value = "",
|
||||
bool valueRequired = false,
|
||||
bool attachmentRequired = false}) async {
|
||||
Map<String, Map<String, dynamic>> fields =
|
||||
InvenTreeStockItemTestResult().formFields();
|
||||
|
||||
// Add additional filters
|
||||
fields["template"]?["filters"]?["part"] = "${item.partId}";
|
||||
@ -102,7 +104,6 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
bool match = false;
|
||||
|
||||
for (var ii = 0; ii < outputs.length; ii++) {
|
||||
|
||||
// Check against templates
|
||||
if (outputs[ii] is InvenTreePartTestTemplate) {
|
||||
var template = outputs[ii] as InvenTreePartTestTemplate;
|
||||
@ -137,23 +138,16 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
List<Widget> getTiles(BuildContext context) {
|
||||
List<Widget> tiles = [];
|
||||
|
||||
tiles.add(
|
||||
Card(
|
||||
tiles.add(Card(
|
||||
child: ListTile(
|
||||
title: Text(item.partName),
|
||||
subtitle: Text(item.partDescription),
|
||||
leading: InvenTreeAPI().getThumbnail(item.partImage),
|
||||
)
|
||||
)
|
||||
);
|
||||
title: Text(item.partName),
|
||||
subtitle: Text(item.partDescription),
|
||||
leading: InvenTreeAPI().getThumbnail(item.partImage),
|
||||
)));
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().testResults,
|
||||
style: TextStyle(fontWeight: FontWeight.bold)
|
||||
)
|
||||
)
|
||||
);
|
||||
style: TextStyle(fontWeight: FontWeight.bold))));
|
||||
|
||||
if (loading) {
|
||||
tiles.add(progressIndicator());
|
||||
@ -172,7 +166,6 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
}
|
||||
|
||||
for (var item in results) {
|
||||
|
||||
bool _hasResult = false;
|
||||
bool _required = false;
|
||||
String _test = "";
|
||||
@ -214,26 +207,23 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
}
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(_test, style: TextStyle(
|
||||
fontWeight: _required ? FontWeight.bold : FontWeight.normal,
|
||||
fontStyle: _hasResult ? FontStyle.normal : FontStyle.italic
|
||||
)),
|
||||
subtitle: Text(_value),
|
||||
trailing: Text(_date),
|
||||
leading: _icon,
|
||||
onTap: () {
|
||||
if (InvenTreeStockItemTestResult().canCreate) {
|
||||
addTestResult(
|
||||
context,
|
||||
name: _test,
|
||||
templateId: _templateId,
|
||||
nameIsEditable: !_required,
|
||||
valueRequired: _valueRequired,
|
||||
attachmentRequired: _attachmentRequired
|
||||
);
|
||||
}
|
||||
}
|
||||
));
|
||||
title: Text(_test,
|
||||
style: TextStyle(
|
||||
fontWeight: _required ? FontWeight.bold : FontWeight.normal,
|
||||
fontStyle: _hasResult ? FontStyle.normal : FontStyle.italic)),
|
||||
subtitle: Text(_value),
|
||||
trailing: Text(_date),
|
||||
leading: _icon,
|
||||
onTap: () {
|
||||
if (InvenTreeStockItemTestResult().canCreate) {
|
||||
addTestResult(context,
|
||||
name: _test,
|
||||
templateId: _templateId,
|
||||
nameIsEditable: !_required,
|
||||
valueRequired: _valueRequired,
|
||||
attachmentRequired: _attachmentRequired);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (tiles.isEmpty) {
|
||||
@ -244,4 +234,4 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
|
||||
return tiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,7 @@ import "package:inventree/widget/refreshable_state.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/api.dart";
|
||||
|
||||
|
||||
class StockItemList extends StatefulWidget {
|
||||
|
||||
const StockItemList(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
@ -18,9 +16,7 @@ class StockItemList extends StatefulWidget {
|
||||
_StockListState createState() => _StockListState(filters);
|
||||
}
|
||||
|
||||
|
||||
class _StockListState extends RefreshableState<StockItemList> {
|
||||
|
||||
_StockListState(this.filters);
|
||||
|
||||
final Map<String, String> filters;
|
||||
@ -35,20 +31,18 @@ class _StockListState extends RefreshableState<StockItemList> {
|
||||
}
|
||||
|
||||
class PaginatedStockItemList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedStockItemList(Map<String, String> filters) : super(filters: filters);
|
||||
const PaginatedStockItemList(Map<String, String> filters)
|
||||
: super(filters: filters);
|
||||
|
||||
@override
|
||||
String get searchTitle => L10().stockItems;
|
||||
|
||||
@override
|
||||
_PaginatedStockItemListState createState() => _PaginatedStockItemListState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockItemList> {
|
||||
|
||||
class _PaginatedStockItemListState
|
||||
extends PaginatedSearchState<PaginatedStockItemList> {
|
||||
_PaginatedStockItemListState() : super();
|
||||
|
||||
@override
|
||||
@ -56,14 +50,14 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
|
||||
|
||||
@override
|
||||
Map<String, String> get orderingOptions => {
|
||||
"part__name": L10().name,
|
||||
"part__IPN": L10().internalPartNumber,
|
||||
"stock": L10().quantity,
|
||||
"status": L10().status,
|
||||
"batch": L10().batchCode,
|
||||
"updated": L10().lastUpdated,
|
||||
"stocktake_date": L10().lastStocktake,
|
||||
};
|
||||
"part__name": L10().name,
|
||||
"part__IPN": L10().internalPartNumber,
|
||||
"stock": L10().quantity,
|
||||
"status": L10().status,
|
||||
"batch": L10().batchCode,
|
||||
"updated": L10().lastUpdated,
|
||||
"stocktake_date": L10().lastStocktake,
|
||||
};
|
||||
|
||||
@override
|
||||
Map<String, Map<String, dynamic>> get filterOptions {
|
||||
@ -111,23 +105,19 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
|
||||
}
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit, int offset, Map<String, String> params) async {
|
||||
// Ensure StockStatus codes are loaded
|
||||
await InvenTreeAPI().StockStatus.load();
|
||||
|
||||
final page = await InvenTreeStockItem().listPaginated(
|
||||
limit,
|
||||
offset,
|
||||
filters: params
|
||||
);
|
||||
final page = await InvenTreeStockItem()
|
||||
.listPaginated(limit, offset, filters: params);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeStockItem item = model as InvenTreeStockItem;
|
||||
|
||||
return ListTile(
|
||||
@ -135,18 +125,18 @@ class _PaginatedStockItemListState extends PaginatedSearchState<PaginatedStockIt
|
||||
subtitle: Text(item.locationPathString),
|
||||
leading: InvenTreeAPI().getThumbnail(item.partThumbnail),
|
||||
trailing: SizedBox(
|
||||
width: 48,
|
||||
child: Text("${item.displayQuantity}",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: InvenTreeAPI().StockStatus.color(item.status),
|
||||
),
|
||||
)
|
||||
),
|
||||
width: 48,
|
||||
child: Text(
|
||||
"${item.displayQuantity}",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: InvenTreeAPI().StockStatus.color(item.status),
|
||||
),
|
||||
)),
|
||||
onTap: () {
|
||||
item.goToDetailPage(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user