Allocated stock table fix (#7636)

* Expose batch code field to StockItemSerializerBrief

* Expose more fields to PartBriefSerializer

* Additional export fields to BuildItemSerializer

* Bump API version

* Fix playwright test
This commit is contained in:
Oliver 2024-07-14 20:49:46 +10:00 committed by GitHub
parent 0db280ad74
commit 750e6d81fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 29 additions and 5 deletions

View File

@ -1,12 +1,17 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 220
INVENTREE_API_VERSION = 221
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v221 - 2024-07-13 : https://github.com/inventree/InvenTree/pull/7636
- Adds missing fields from StockItemBriefSerializer
- Adds missing fields from PartBriefSerializer
- Adds extra exportable fields to BuildItemSerializer
v220 - 2024-07-11 : https://github.com/inventree/InvenTree/pull/7585
- Adds "revision_of" field to Part serializer
- Adds new API filters for "revision" status

View File

@ -1072,6 +1072,8 @@ class BuildItemSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali
'part_name',
'part_ipn',
'available_quantity',
'item_batch_code',
'item_serial',
]
class Meta:
@ -1103,6 +1105,8 @@ class BuildItemSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali
'part_name',
'part_ipn',
'available_quantity',
'item_batch_code',
'item_serial_number',
]
def __init__(self, *args, **kwargs):
@ -1138,6 +1142,9 @@ class BuildItemSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali
part_name = serializers.CharField(source='stock_item.part.name', label=_('Part Name'), read_only=True)
part_ipn = serializers.CharField(source='stock_item.part.IPN', label=_('Part IPN'), read_only=True)
item_batch_code = serializers.CharField(source='stock_item.batch', label=_('Batch Code'), read_only=True)
item_serial_number = serializers.CharField(source='stock_item.serial', label=_('Serial Number'), read_only=True)
# Annotated fields
build = serializers.PrimaryKeyRelatedField(source='build_line.build', many=False, read_only=True)

View File

@ -309,7 +309,9 @@ class PartBriefSerializer(InvenTree.serializers.InvenTreeModelSerializer):
'image',
'thumbnail',
'active',
'locked',
'assembly',
'component',
'is_template',
'purchaseable',
'salable',

View File

@ -306,6 +306,7 @@ class StockItemSerializerBrief(
'location',
'quantity',
'serial',
'batch',
'supplier_part',
'barcode_hash',
]

View File

@ -57,7 +57,6 @@ import {
useEditApiFormModal
} from '../../hooks/UseForm';
import { useInstance } from '../../hooks/UseInstance';
import { apiUrl } from '../../states/ApiState';
import { useUserState } from '../../states/UserState';
import { AttachmentTable } from '../../tables/general/AttachmentTable';
import InstalledItemsTable from '../../tables/stock/InstalledItemsTable';

View File

@ -2,6 +2,7 @@ import { t } from '@lingui/macro';
import { useCallback, useMemo, useState } from 'react';
import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType';
import { UserRoles } from '../../enums/Roles';
import {
useDeleteApiFormModal,
@ -58,6 +59,13 @@ export default function BuildAllocatedStockTable({
sortable: true,
switchable: false
},
{
accessor: 'serial',
title: t`Serial Number`,
sortable: false,
switchable: true,
render: (record: any) => record?.stock_item_detail?.serial
},
{
accessor: 'batch',
title: t`Batch Code`,
@ -150,7 +158,9 @@ export default function BuildAllocatedStockTable({
enableDownload: true,
enableSelection: true,
rowActions: rowActions,
tableFilters: tableFilters
tableFilters: tableFilters,
modelField: 'stock_item',
modelType: ModelType.stockitem
}}
/>
</>

View File

@ -19,10 +19,10 @@ test('PUI - Pages - Build Order', async ({ page }) => {
await page.getByRole('tab', { name: 'Allocated Stock' }).click();
// Check for expected text in the table
await page.getByText('R_10R_0402_1%').click();
await page.getByText('R_10R_0402_1%').waitFor();
await page
.getByRole('cell', { name: 'R38, R39, R40, R41, R42, R43' })
.click();
.waitFor();
// Click through to the "parent" build
await page.getByRole('tab', { name: 'Build Details' }).click();