Skip to content

Commit fbe222f

Browse files
Fix for "installed in" display (inventree#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 878fba9. * Bump API version * Add playwright tests
1 parent ac63b10 commit fbe222f

8 files changed

Lines changed: 47 additions & 5 deletions

File tree

docs/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def check_link(url) -> bool:
5353
if url in cache:
5454
return True
5555

56+
print(f'Checking external URL: {url}')
57+
5658
attempts = 5
5759

5860
while attempts > 0:
@@ -66,6 +68,8 @@ def check_link(url) -> bool:
6668

6769
attempts -= 1
6870

71+
print(f' - URL check failed with status code {response.status_code}')
72+
6973
return False
7074

7175

src/backend/InvenTree/InvenTree/api_version.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
"""InvenTree API version information."""
22

33
# InvenTree API version
4-
INVENTREE_API_VERSION = 280
4+
INVENTREE_API_VERSION = 281
55

66
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
77

88

99
INVENTREE_API_TEXT = """
1010
11+
v281 - 2024-11-15 : https://github.com/inventree/InvenTree/pull/8480
12+
- Fixes StockHistory API data serialization
13+
1114
v280 - 2024-11-10 : https://github.com/inventree/InvenTree/pull/8461
1215
- Makes schema for API information endpoint more informing
1316
- Removes general not found endpoint

src/backend/InvenTree/stock/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,8 @@ def get_delta_model_map(self) -> dict:
13971397
'salesorder': (SalesOrder, SalesOrderSerializer),
13981398
'returnorder': (ReturnOrder, ReturnOrderSerializer),
13991399
'buildorder': (Build, BuildSerializer),
1400+
'item': (StockItem, StockSerializers.StockItemSerializer),
1401+
'stockitem': (StockItem, StockSerializers.StockItemSerializer),
14001402
}
14011403

14021404
def list(self, request, *args, **kwargs):

src/backend/InvenTree/stock/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class Meta:
425425

426426
def __init__(self, *args, **kwargs):
427427
"""Add detail fields."""
428-
part_detail = kwargs.pop('part_detail', False)
428+
part_detail = kwargs.pop('part_detail', True)
429429
location_detail = kwargs.pop('location_detail', False)
430430
supplier_part_detail = kwargs.pop('supplier_part_detail', False)
431431
tests = kwargs.pop('tests', False)

src/frontend/src/components/details/Details.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type InternalLinkField = {
6767
model: ModelType;
6868
model_field?: string;
6969
model_formatter?: (value: any) => string;
70+
model_filters?: any;
7071
backup_value?: string;
7172
};
7273

@@ -234,7 +235,9 @@ function TableAnchorValue(props: Readonly<FieldProps>) {
234235
const url = apiUrl(modelDef.api_endpoint, props.field_value);
235236

236237
return api
237-
.get(url)
238+
.get(url, {
239+
params: props.field_data.model_filters ?? undefined
240+
})
238241
.then((response) => {
239242
switch (response.status) {
240243
case 200:

src/frontend/src/pages/stock/StockDetail.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,13 @@ export default function StockDetail() {
211211
type: 'link',
212212
name: 'belongs_to',
213213
label: t`Installed In`,
214+
model_filters: {
215+
part_detail: true
216+
},
214217
model_formatter: (model: any) => {
215218
let text = model?.part_detail?.full_name ?? model?.name;
216219
if (model.serial && model.quantity == 1) {
217-
text += `# ${model.serial}`;
220+
text += ` # ${model.serial}`;
218221
}
219222

220223
return text;

src/frontend/src/tables/stock/StockTrackingTable.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ export function StockTrackingTable({ itemId }: Readonly<{ itemId: number }>) {
5050
key: 'stockitem',
5151
details:
5252
deltas.stockitem_detail &&
53-
RenderStockItem({ instance: deltas.stockitem_detail })
53+
RenderStockItem({ instance: deltas.stockitem_detail, link: true })
54+
},
55+
{
56+
label: t`Stock Item`,
57+
key: 'item',
58+
details:
59+
deltas.item_detail &&
60+
RenderStockItem({
61+
instance: deltas.item_detail,
62+
link: true
63+
})
5464
},
5565
{
5666
label: t`Status`,

src/frontend/tests/pages/pui_stock.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,20 @@ test('Stock - Stock Actions', async ({ page }) => {
157157

158158
await page.waitForTimeout(2500);
159159
});
160+
161+
test('Stock - Tracking', async ({ page }) => {
162+
await doQuickLogin(page);
163+
164+
// Navigate to the "stock item" page
165+
await page.goto(`${baseUrl}/stock/item/176/details/`);
166+
await page.getByRole('link', { name: 'Widget Assembly # 2' }).waitFor();
167+
168+
// Navigate to the "stock tracking" tab
169+
await page.getByRole('tab', { name: 'Stock Tracking' }).click();
170+
await page.getByText('- - Factory/Office Block/Room').first().waitFor();
171+
await page.getByRole('link', { name: 'Widget Assembly' }).waitFor();
172+
await page.getByRole('cell', { name: 'Installed into assembly' }).waitFor();
173+
174+
await page.waitForTimeout(1500);
175+
return;
176+
});

0 commit comments

Comments
 (0)