2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 19:46:46 +00:00

Fix for "installed in" display (#8480)

* Fix for "installed in" display

- Allow "details" field to be passed custom params

* Add extra debug to link checking

* API: fix for StockTrackingList entry

* Display links for stock items in tracking entry table

* Generate absolute links for item renderers

* Revert "Generate absolute links for item renderers"

This reverts commit 878fba91d0d689f49dfdee964827227fe574a66b.

* Bump API version

* Add playwright tests
This commit is contained in:
Oliver 2024-11-15 23:28:47 +11:00 committed by GitHub
parent ac63b10197
commit fbe222f6eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 47 additions and 5 deletions

View File

@ -53,6 +53,8 @@ def check_link(url) -> bool:
if url in cache:
return True
print(f'Checking external URL: {url}')
attempts = 5
while attempts > 0:
@ -66,6 +68,8 @@ def check_link(url) -> bool:
attempts -= 1
print(f' - URL check failed with status code {response.status_code}')
return False

View File

@ -1,13 +1,16 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 280
INVENTREE_API_VERSION = 281
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v281 - 2024-11-15 : https://github.com/inventree/InvenTree/pull/8480
- Fixes StockHistory API data serialization
v280 - 2024-11-10 : https://github.com/inventree/InvenTree/pull/8461
- Makes schema for API information endpoint more informing
- Removes general not found endpoint

View File

@ -1397,6 +1397,8 @@ class StockTrackingList(DataExportViewMixin, ListAPI):
'salesorder': (SalesOrder, SalesOrderSerializer),
'returnorder': (ReturnOrder, ReturnOrderSerializer),
'buildorder': (Build, BuildSerializer),
'item': (StockItem, StockSerializers.StockItemSerializer),
'stockitem': (StockItem, StockSerializers.StockItemSerializer),
}
def list(self, request, *args, **kwargs):

View File

@ -425,7 +425,7 @@ class StockItemSerializer(
def __init__(self, *args, **kwargs):
"""Add detail fields."""
part_detail = kwargs.pop('part_detail', False)
part_detail = kwargs.pop('part_detail', True)
location_detail = kwargs.pop('location_detail', False)
supplier_part_detail = kwargs.pop('supplier_part_detail', False)
tests = kwargs.pop('tests', False)

View File

@ -67,6 +67,7 @@ type InternalLinkField = {
model: ModelType;
model_field?: string;
model_formatter?: (value: any) => string;
model_filters?: any;
backup_value?: string;
};
@ -234,7 +235,9 @@ function TableAnchorValue(props: Readonly<FieldProps>) {
const url = apiUrl(modelDef.api_endpoint, props.field_value);
return api
.get(url)
.get(url, {
params: props.field_data.model_filters ?? undefined
})
.then((response) => {
switch (response.status) {
case 200:

View File

@ -211,6 +211,9 @@ export default function StockDetail() {
type: 'link',
name: 'belongs_to',
label: t`Installed In`,
model_filters: {
part_detail: true
},
model_formatter: (model: any) => {
let text = model?.part_detail?.full_name ?? model?.name;
if (model.serial && model.quantity == 1) {

View File

@ -50,7 +50,17 @@ export function StockTrackingTable({ itemId }: Readonly<{ itemId: number }>) {
key: 'stockitem',
details:
deltas.stockitem_detail &&
RenderStockItem({ instance: deltas.stockitem_detail })
RenderStockItem({ instance: deltas.stockitem_detail, link: true })
},
{
label: t`Stock Item`,
key: 'item',
details:
deltas.item_detail &&
RenderStockItem({
instance: deltas.item_detail,
link: true
})
},
{
label: t`Status`,

View File

@ -157,3 +157,20 @@ test('Stock - Stock Actions', async ({ page }) => {
await page.waitForTimeout(2500);
});
test('Stock - Tracking', async ({ page }) => {
await doQuickLogin(page);
// Navigate to the "stock item" page
await page.goto(`${baseUrl}/stock/item/176/details/`);
await page.getByRole('link', { name: 'Widget Assembly # 2' }).waitFor();
// Navigate to the "stock tracking" tab
await page.getByRole('tab', { name: 'Stock Tracking' }).click();
await page.getByText('- - Factory/Office Block/Room').first().waitFor();
await page.getByRole('link', { name: 'Widget Assembly' }).waitFor();
await page.getByRole('cell', { name: 'Installed into assembly' }).waitFor();
await page.waitForTimeout(1500);
return;
});