2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00
inventree-app/lib/widget/stock/location_list.dart
Oliver bdd5470e68
Sales order support (#438)
* Add new models for SalesOrder

- Create generic Order and OrderLine models with common functionality

* Refactor

- Move some widgets around
- Cleanup directory structure

* Add link to home screen and nav drawer

* Add SalesOrder list widget

* Linting fixes

* Fix string

* Refactor PurchaseOrderDetailWidget

* Tweaks to existing code

* linting

* Fixes for drawer widget

* Add "detail" page for SalesOrder

* Add more tiles to SalesOrder detail

* Allow editing of salesorder

* add list filters for sales orders

* Display list of line items

* Customer updates

- Display customer icon on home screen
- Fetch sales orders for customer detail page

* Cleanup company detail view

* Create new sales order from list

* Stricter typing for formFields method

* Create new PurchaseOrder and SalesOrder from company deatil

* Status code updates

- Add function for name comparison
- Remove hard-coded values

* Update view permission checks for home widget

* Add ability to manually add SalesOrderLineItem

* Add nice progress bar widgets

* Display detail view for sales order line item

* edit SalesOrderLineItem

* Fix unused import

* Hide "shipped items" tab

- Will be added in a future update
2023-11-12 23:13:22 +11:00

99 lines
2.5 KiB
Dart

import "package:flutter/material.dart";
import "package:inventree/inventree/model.dart";
import "package:inventree/inventree/stock.dart";
import "package:inventree/widget/stock/location_display.dart";
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;
@override
_StockLocationListState createState() => _StockLocationListState(filters);
}
class _StockLocationListState extends RefreshableState<StockLocationList> {
_StockLocationListState(this.filters);
final Map<String, String> filters;
@override
String getAppBarTitle() => L10().stockLocations;
@override
Widget getBody(BuildContext context) {
return PaginatedStockLocationList(filters);
}
}
class PaginatedStockLocationList extends PaginatedSearchWidget {
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();
}
class _PaginatedStockLocationListState extends PaginatedSearchState<PaginatedStockLocationList> {
_PaginatedStockLocationListState() : super();
@override
Map<String, String> get orderingOptions => {
"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,
}
};
@override
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(
title: Text(location.name),
subtitle: Text(location.pathstring),
trailing: Text("${location.itemcount}"),
leading: location.customIcon,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LocationDisplayWidget(location)
)
);
},
);
}
}