Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for "installed in" display #8480

Merged
merged 11 commits into from
Nov 15, 2024
4 changes: 4 additions & 0 deletions docs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -66,6 +68,8 @@ def check_link(url) -> bool:

attempts -= 1

print(f' - URL check failed with status code {response.status_code}')

return False


Expand Down
5 changes: 4 additions & 1 deletion src/backend/InvenTree/InvenTree/api_version.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/backend/InvenTree/stock/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,8 @@ def get_delta_model_map(self) -> dict:
'salesorder': (SalesOrder, SalesOrderSerializer),
'returnorder': (ReturnOrder, ReturnOrderSerializer),
'buildorder': (Build, BuildSerializer),
'item': (StockItem, StockSerializers.StockItemSerializer),
'stockitem': (StockItem, StockSerializers.StockItemSerializer),
}

def list(self, request, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/stock/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ class Meta:

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)
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/src/components/details/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type InternalLinkField = {
model: ModelType;
model_field?: string;
model_formatter?: (value: any) => string;
model_filters?: any;
backup_value?: string;
};

Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/src/pages/stock/StockDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,13 @@ 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) {
text += `# ${model.serial}`;
text += ` # ${model.serial}`;
}

return text;
Expand Down
12 changes: 11 additions & 1 deletion src/frontend/src/tables/stock/StockTrackingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
17 changes: 17 additions & 0 deletions src/frontend/tests/pages/pui_stock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Loading