mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-15 19:55:27 +00:00
Refactor createFromJson function
This commit is contained in:
@ -12,9 +12,7 @@ class InvenTreeBomItem extends InvenTreeModel {
|
||||
InvenTreeBomItem.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreeBomItem.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeBomItem.fromJson(json);
|
||||
|
||||
@override
|
||||
String get URL => "bom/";
|
||||
|
@ -81,11 +81,7 @@ class InvenTreeCompany extends InvenTreeModel {
|
||||
}
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
var company = InvenTreeCompany.fromJson(json);
|
||||
|
||||
return company;
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeCompany.fromJson(json);
|
||||
}
|
||||
|
||||
|
||||
@ -183,11 +179,7 @@ class InvenTreeSupplierPart extends InvenTreeModel {
|
||||
String get note => getString("note");
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
var part = InvenTreeSupplierPart.fromJson(json);
|
||||
|
||||
return part;
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeSupplierPart.fromJson(json);
|
||||
}
|
||||
|
||||
|
||||
@ -214,9 +206,5 @@ class InvenTreeManufacturerPart extends InvenTreeModel {
|
||||
String get MPN => getString("MPN");
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
var part = InvenTreeManufacturerPart.fromJson(json);
|
||||
|
||||
return part;
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeManufacturerPart.fromJson(json);
|
||||
}
|
||||
|
@ -390,12 +390,7 @@ class InvenTreeModel {
|
||||
String get keywords => getString("keywords");
|
||||
|
||||
// Create a new object from JSON data (not a constructor!)
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
|
||||
var obj = InvenTreeModel.fromJson(json);
|
||||
|
||||
return obj;
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeModel.fromJson(json);
|
||||
|
||||
// Return the API detail endpoint for this Model object
|
||||
String get url => "${URL}/${pk}/".replaceAll("//", "/");
|
||||
@ -836,9 +831,7 @@ class InvenTreePlugin extends InvenTreeModel {
|
||||
InvenTreePlugin.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreePlugin.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreePlugin.fromJson(json);
|
||||
|
||||
@override
|
||||
String get URL {
|
||||
|
@ -67,11 +67,7 @@ class InvenTreePartCategory extends InvenTreeModel {
|
||||
int get partcount => (jsondata["part_count"] ?? jsondata["parts"] ?? 0) as int;
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
var cat = InvenTreePartCategory.fromJson(json);
|
||||
|
||||
return cat;
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreePartCategory.fromJson(json);
|
||||
}
|
||||
|
||||
|
||||
@ -98,11 +94,7 @@ class InvenTreePartTestTemplate extends InvenTreeModel {
|
||||
bool get requiresAttachment => getBool("requires_attachment");
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
var template = InvenTreePartTestTemplate.fromJson(json);
|
||||
|
||||
return template;
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreePartTestTemplate.fromJson(json);
|
||||
|
||||
bool passFailStatus() {
|
||||
|
||||
@ -142,9 +134,7 @@ class InvenTreePartParameter extends InvenTreeModel {
|
||||
String get URL => "part/parameter/";
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreePartParameter.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreePartParameter.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> formFields() {
|
||||
@ -445,12 +435,7 @@ class InvenTreePart extends InvenTreeModel {
|
||||
bool get starred => getBool("starred");
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
|
||||
var part = InvenTreePart.fromJson(json);
|
||||
|
||||
return part;
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreePart.fromJson(json);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -469,8 +454,6 @@ class InvenTreePartAttachment extends InvenTreeAttachment {
|
||||
String get URL => "part/attachment/";
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreePartAttachment.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreePartAttachment.fromJson(json);
|
||||
|
||||
}
|
||||
|
@ -134,9 +134,7 @@ class InvenTreePurchaseOrder extends InvenTreeModel {
|
||||
}
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreePurchaseOrder.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreePurchaseOrder.fromJson(json);
|
||||
|
||||
/// Mark this order as "placed" / "issued"
|
||||
Future<void> issueOrder() async {
|
||||
@ -243,9 +241,8 @@ class InvenTreePOLineItem extends InvenTreeModel {
|
||||
Map<String, dynamic> get destinationDetail => getMap("destination_detail");
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreePOLineItem.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreePOLineItem.fromJson(json);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -264,7 +261,6 @@ class InvenTreePurchaseOrderAttachment extends InvenTreeAttachment {
|
||||
String get URL => "order/po/attachment/";
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreePurchaseOrderAttachment.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreePurchaseOrderAttachment.fromJson(json);
|
||||
|
||||
}
|
||||
|
@ -63,9 +63,7 @@ class InvenTreeStockItemHistory extends InvenTreeModel {
|
||||
InvenTreeStockItemHistory.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreeStockItemHistory.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeStockItemHistory.fromJson(json);
|
||||
|
||||
@override
|
||||
String get URL => "stock/track/";
|
||||
@ -472,9 +470,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
}
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreeStockItem.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeStockItem.fromJson(json);
|
||||
|
||||
/*
|
||||
* Perform stocktake action:
|
||||
@ -576,9 +572,7 @@ class InvenTreeStockItemAttachment extends InvenTreeAttachment {
|
||||
String get URL => "stock/attachment/";
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreeStockItemAttachment.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeStockItemAttachment.fromJson(json);
|
||||
|
||||
}
|
||||
|
||||
@ -633,10 +627,6 @@ class InvenTreeStockLocation extends InvenTreeModel {
|
||||
int get itemcount => (jsondata["items"] ?? 0) as int;
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeStockLocation.fromJson(json);
|
||||
|
||||
var loc = InvenTreeStockLocation.fromJson(json);
|
||||
|
||||
return loc;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user