mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-01 09:31:34 +00:00
Request column names from server when loading table (#6375)
* Request column names from server when loading table - As these are translated by the server, we can make use of them on the client side! - Reduces duplication of translated titles * Move tables up one level * Cache translated table column names * Clear table column cache whenever we change locale context * Fix cache behavioue * Enforce titleCase for table column names * Refactor BuildOrder table * Refactor Company table * Refactor order tables * More refactoring - Refactoring more columns * Update more tables * Refactor BomTable * Remove toTitleCase - We will rely on the server-side translations! * Remove debug messages * Update src/frontend/src/tables/InvenTreeTable.tsx Co-authored-by: Matthias Mair <code@mjmair.com> * Cleanup * Update docstring * Cleanup * Support nested fields with dot notation - Powerful code reuse is powerful * Complete refactor for BuildLine table - Add some missing field descriptors on the backend * Cleanup hooks a bit * Update BomTable * Allow table filters to make use of the same info * Add ReferenceColumn helper * Use queryParams when fetching table OPTIONS - Required to ensure the same columns are fetched * More refactoring * Fix ProjectCodeTable * Code cleanup * Fix unused var --------- Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
InvenTree
src/frontend/src
components
images
contexts
functions
hooks
pages
states
tables
Column.tsxColumnRenderers.tsxColumnSelect.tsxDetails.tsxDownloadAction.tsxFilter.tsxFilterSelectDrawer.tsxInvenTreeTable.tsxItemDetails.tsxRowActions.tsxSearch.tsxTableHoverCard.tsx
bom
build
company
general
notifications
part
PartCategoryTable.tsxPartParameterTable.tsxPartParameterTemplateTable.tsxPartTable.tsxPartTestTemplateTable.tsxPartThumbTable.tsxPartVariantTable.tsxRelatedPartTable.tsx
plugin
purchasing
ManufacturerPartParameterTable.tsxManufacturerPartTable.tsxPurchaseOrderLineItemTable.tsxPurchaseOrderTable.tsxSupplierPartTable.tsx
sales
settings
CurrencyTable.tsxCustomUnitsTable.tsxErrorTable.tsxFailedTasksTable.tsxGroupTable.tsxPendingTasksTable.tsxProjectCodeTable.tsxScheduledTasksTable.tsxUserTable.tsx
stock
views
@@ -1075,16 +1075,34 @@ class BuildLineSerializer(InvenTreeModelSerializer):
|
||||
|
||||
quantity = serializers.FloatField()
|
||||
|
||||
bom_item = serializers.PrimaryKeyRelatedField(label=_('Bom Item'), read_only=True)
|
||||
|
||||
# Foreign key fields
|
||||
bom_item_detail = BomItemSerializer(source='bom_item', many=False, read_only=True, pricing=False)
|
||||
part_detail = PartSerializer(source='bom_item.sub_part', many=False, read_only=True, pricing=False)
|
||||
allocations = BuildItemSerializer(many=True, read_only=True)
|
||||
|
||||
# Annotated (calculated) fields
|
||||
allocated = serializers.FloatField(read_only=True)
|
||||
on_order = serializers.FloatField(read_only=True)
|
||||
in_production = serializers.FloatField(read_only=True)
|
||||
available_stock = serializers.FloatField(read_only=True)
|
||||
allocated = serializers.FloatField(
|
||||
label=_('Allocated Stock'),
|
||||
read_only=True
|
||||
)
|
||||
|
||||
on_order = serializers.FloatField(
|
||||
label=_('On Order'),
|
||||
read_only=True
|
||||
)
|
||||
|
||||
in_production = serializers.FloatField(
|
||||
label=_('In Production'),
|
||||
read_only=True
|
||||
)
|
||||
|
||||
available_stock = serializers.FloatField(
|
||||
label=_('Available Stock'),
|
||||
read_only=True
|
||||
)
|
||||
|
||||
available_substitute_stock = serializers.FloatField(read_only=True)
|
||||
available_variant_stock = serializers.FloatField(read_only=True)
|
||||
total_available_stock = serializers.FloatField(read_only=True)
|
||||
|
@@ -1408,8 +1408,9 @@ class BomItemSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
||||
|
||||
sub_part_detail = PartBriefSerializer(source='sub_part', many=False, read_only=True)
|
||||
|
||||
on_order = serializers.FloatField(read_only=True)
|
||||
building = serializers.FloatField(read_only=True)
|
||||
on_order = serializers.FloatField(label=_('On Order'), read_only=True)
|
||||
|
||||
building = serializers.FloatField(label=_('In Production'), read_only=True)
|
||||
|
||||
# Cached pricing fields
|
||||
pricing_min = InvenTree.serializers.InvenTreeMoneySerializer(
|
||||
@@ -1420,7 +1421,8 @@ class BomItemSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
||||
)
|
||||
|
||||
# Annotated fields for available stock
|
||||
available_stock = serializers.FloatField(read_only=True)
|
||||
available_stock = serializers.FloatField(label=_('Available Stock'), read_only=True)
|
||||
|
||||
available_substitute_stock = serializers.FloatField(read_only=True)
|
||||
available_variant_stock = serializers.FloatField(read_only=True)
|
||||
|
||||
|
Reference in New Issue
Block a user