mirror of
https://github.com/inventree/InvenTree.git
synced 2026-04-16 08:18:53 +00:00
Receive virtual parts (#11627)
* Handle receive of virtual parts - Update line item quantity - Do not add any stock * Add unit test * Additional unit test * UI form improvements * Add playwright test * Updated playwright tests
This commit is contained in:
@@ -106,7 +106,7 @@ export function usePartFields({
|
||||
};
|
||||
|
||||
// Additional fields for creation
|
||||
if (create) {
|
||||
if (create && !virtual) {
|
||||
fields.copy_category_parameters = {};
|
||||
|
||||
if (virtual != false) {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import {
|
||||
ActionIcon,
|
||||
Alert,
|
||||
Container,
|
||||
Flex,
|
||||
FocusTrap,
|
||||
Group,
|
||||
HoverCard,
|
||||
Modal,
|
||||
Table,
|
||||
TextInput
|
||||
@@ -15,6 +18,7 @@ import {
|
||||
IconCoins,
|
||||
IconCurrencyDollar,
|
||||
IconHash,
|
||||
IconInfoCircle,
|
||||
IconLink,
|
||||
IconList,
|
||||
IconNotes,
|
||||
@@ -488,6 +492,12 @@ function LineItemFormRow({
|
||||
return text;
|
||||
}, [location]);
|
||||
|
||||
// Handle virtual parts
|
||||
const virtual = useMemo(
|
||||
() => record.part_detail?.virtual ?? false,
|
||||
[record.part_detail]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
@@ -506,14 +516,30 @@ function LineItemFormRow({
|
||||
</Modal>
|
||||
<Table.Tr>
|
||||
<Table.Td>
|
||||
<Flex gap='sm' align='center'>
|
||||
<Thumbnail
|
||||
size={40}
|
||||
src={record.part_detail.thumbnail}
|
||||
align='center'
|
||||
/>
|
||||
<div>{record.part_detail.name}</div>
|
||||
</Flex>
|
||||
<Group gap='xs' justify='space-between'>
|
||||
<Group gap='xs' justify='left'>
|
||||
<Thumbnail
|
||||
size={40}
|
||||
src={record.part_detail.thumbnail}
|
||||
align='center'
|
||||
/>
|
||||
<div>{record.part_detail.name}</div>
|
||||
</Group>
|
||||
{virtual && (
|
||||
<HoverCard>
|
||||
<HoverCard.Target>
|
||||
<ActionIcon color='blue' variant='transparent'>
|
||||
<IconInfoCircle />
|
||||
</ActionIcon>
|
||||
</HoverCard.Target>
|
||||
<HoverCard.Dropdown>
|
||||
<Alert color='blue' title={t`Virtual Part`}>
|
||||
{t`This part is virtual, no physical stock will be received.`}
|
||||
</Alert>
|
||||
</HoverCard.Dropdown>
|
||||
</HoverCard>
|
||||
)}
|
||||
</Group>
|
||||
</Table.Td>
|
||||
<Table.Td>{record.supplier_part_detail.SKU}</Table.Td>
|
||||
<Table.Td>
|
||||
@@ -546,6 +572,7 @@ function LineItemFormRow({
|
||||
tooltip={t`Set Location`}
|
||||
tooltipAlignment='top'
|
||||
variant={locationOpen ? 'outline' : 'transparent'}
|
||||
disabled={virtual}
|
||||
/>
|
||||
<ActionButton
|
||||
size='sm'
|
||||
@@ -554,6 +581,7 @@ function LineItemFormRow({
|
||||
tooltip={t`Assign Batch Code`}
|
||||
tooltipAlignment='top'
|
||||
variant={batchOpen ? 'outline' : 'transparent'}
|
||||
disabled={virtual}
|
||||
/>
|
||||
{trackable && (
|
||||
<ActionButton
|
||||
@@ -563,6 +591,7 @@ function LineItemFormRow({
|
||||
tooltip={t`Assign Serial Numbers`}
|
||||
tooltipAlignment='top'
|
||||
variant={serialOpen ? 'outline' : 'transparent'}
|
||||
disabled={virtual}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -574,6 +603,7 @@ function LineItemFormRow({
|
||||
tooltip={t`Set Expiry Date`}
|
||||
tooltipAlignment='top'
|
||||
variant={expiryDateOpen ? 'outline' : 'transparent'}
|
||||
disabled={virtual}
|
||||
/>
|
||||
)}
|
||||
<ActionButton
|
||||
@@ -583,6 +613,7 @@ function LineItemFormRow({
|
||||
tooltipAlignment='top'
|
||||
onClick={() => packagingHandlers.toggle()}
|
||||
variant={packagingOpen ? 'outline' : 'transparent'}
|
||||
disabled={virtual}
|
||||
/>
|
||||
<ActionButton
|
||||
onClick={() => statusHandlers.toggle()}
|
||||
@@ -590,6 +621,7 @@ function LineItemFormRow({
|
||||
tooltip={t`Change Status`}
|
||||
tooltipAlignment='top'
|
||||
variant={statusOpen ? 'outline' : 'transparent'}
|
||||
disabled={virtual}
|
||||
/>
|
||||
<ActionButton
|
||||
icon={<InvenTreeIcon icon='note' />}
|
||||
@@ -597,6 +629,7 @@ function LineItemFormRow({
|
||||
tooltipAlignment='top'
|
||||
variant={noteOpen ? 'outline' : 'transparent'}
|
||||
onClick={() => noteHandlers.toggle()}
|
||||
disabled={virtual}
|
||||
/>
|
||||
{barcode ? (
|
||||
<ActionButton
|
||||
@@ -606,6 +639,7 @@ function LineItemFormRow({
|
||||
variant='filled'
|
||||
color='red'
|
||||
onClick={() => setBarcode(undefined)}
|
||||
disabled={virtual}
|
||||
/>
|
||||
) : (
|
||||
<ActionButton
|
||||
@@ -614,6 +648,7 @@ function LineItemFormRow({
|
||||
tooltipAlignment='top'
|
||||
variant='transparent'
|
||||
onClick={() => open()}
|
||||
disabled={virtual}
|
||||
/>
|
||||
)}
|
||||
</Flex>
|
||||
|
||||
@@ -281,11 +281,7 @@ function partTableFilters(): TableFilter[] {
|
||||
name: 'virtual',
|
||||
label: t`Virtual`,
|
||||
description: t`Filter by parts which are virtual`,
|
||||
type: 'choice',
|
||||
choices: [
|
||||
{ value: 'true', label: t`Virtual` },
|
||||
{ value: 'false', label: t`Not Virtual` }
|
||||
]
|
||||
type: 'boolean'
|
||||
},
|
||||
{
|
||||
name: 'is_template',
|
||||
|
||||
@@ -82,13 +82,13 @@ test('Company - Supplier Parts', async ({ browser }) => {
|
||||
await loadTab(page, 'Supplier Parts');
|
||||
await clearTableFilters(page);
|
||||
|
||||
await page.getByText('- 25 / 777').waitFor();
|
||||
await page.getByText(/1 \- 25 \/ 77\d/).waitFor();
|
||||
|
||||
await setTableChoiceFilter(page, 'Primary', 'Yes');
|
||||
await page.getByText('- 25 / 318').waitFor();
|
||||
await page.getByText(/1 \- 25 \/ 31\d/).waitFor();
|
||||
|
||||
await clearTableFilters(page);
|
||||
|
||||
await setTableChoiceFilter(page, 'Primary', 'No');
|
||||
await page.getByText('- 25 / 459').waitFor();
|
||||
await page.getByText(/1 \- 25 \/ 45\d/).waitFor();
|
||||
});
|
||||
|
||||
@@ -500,6 +500,39 @@ test('Purchase Orders - Receive Items', async ({ browser }) => {
|
||||
await page.getByRole('cell', { name: 'my-batch-code' }).first().waitFor();
|
||||
});
|
||||
|
||||
test('Purchase Orders - Receive Virtual Items', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
url: 'purchasing/purchase-order/19'
|
||||
});
|
||||
|
||||
// Duplicate this order
|
||||
await page.getByRole('button', { name: 'action-menu-order-actions' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Duplicate' }).click();
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
await page.getByRole('tab', { name: 'Order Details' }).waitFor();
|
||||
|
||||
// Issue the new order
|
||||
await page.getByRole('button', { name: 'Issue Order' }).click();
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
// Receive the line item
|
||||
await loadTab(page, 'Line Items');
|
||||
await page.getByRole('checkbox', { name: 'Select all records' }).click();
|
||||
await page
|
||||
.getByRole('button', { name: 'action-button-receive-items' })
|
||||
.click();
|
||||
|
||||
await page
|
||||
.getByRole('combobox', { name: 'related-field-location' })
|
||||
.fill('factory');
|
||||
await page.getByText('Factory/Storage Room A').click();
|
||||
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
// 1/1 items received
|
||||
await page.getByText('1 / 1', { exact: true }).waitFor();
|
||||
});
|
||||
|
||||
test('Purchase Orders - Duplicate', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
url: 'purchasing/purchase-order/13/detail'
|
||||
|
||||
Reference in New Issue
Block a user