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

PUI: Show "Return from customer" option (#8345)

* PUI: Show "Return from customer" option

* Extend playwright tests

* Additional unit tests
This commit is contained in:
Oliver 2024-10-23 23:24:21 +11:00 committed by GitHub
parent 46cbdac6ba
commit ba3bac10a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 56 additions and 6 deletions

View File

@ -631,6 +631,7 @@ export default function StockDetail() {
}); });
const stockActions = useMemo(() => { const stockActions = useMemo(() => {
const inStock = stockitem.in_stock;
const serial = stockitem.serial; const serial = stockitem.serial;
const serialized = const serialized =
serial != null && serial != null &&
@ -654,13 +655,12 @@ export default function StockDetail() {
/>, />,
<ActionDropdown <ActionDropdown
tooltip={t`Stock Operations`} tooltip={t`Stock Operations`}
hidden={!stockitem.in_stock}
icon={<IconPackages />} icon={<IconPackages />}
actions={[ actions={[
{ {
name: t`Count`, name: t`Count`,
tooltip: t`Count stock`, tooltip: t`Count stock`,
hidden: serialized, hidden: serialized || !inStock,
icon: ( icon: (
<InvenTreeIcon icon="stocktake" iconProps={{ color: 'blue' }} /> <InvenTreeIcon icon="stocktake" iconProps={{ color: 'blue' }} />
), ),
@ -671,7 +671,7 @@ export default function StockDetail() {
{ {
name: t`Add`, name: t`Add`,
tooltip: t`Add Stock`, tooltip: t`Add Stock`,
hidden: serialized, hidden: serialized || !inStock,
icon: <InvenTreeIcon icon="add" iconProps={{ color: 'green' }} />, icon: <InvenTreeIcon icon="add" iconProps={{ color: 'green' }} />,
onClick: () => { onClick: () => {
stockitem.pk && addStockItem.open(); stockitem.pk && addStockItem.open();
@ -680,7 +680,7 @@ export default function StockDetail() {
{ {
name: t`Remove`, name: t`Remove`,
tooltip: t`Remove Stock`, tooltip: t`Remove Stock`,
hidden: serialized, hidden: serialized || !inStock,
icon: <InvenTreeIcon icon="remove" iconProps={{ color: 'red' }} />, icon: <InvenTreeIcon icon="remove" iconProps={{ color: 'red' }} />,
onClick: () => { onClick: () => {
stockitem.pk && removeStockItem.open(); stockitem.pk && removeStockItem.open();
@ -689,7 +689,10 @@ export default function StockDetail() {
{ {
name: t`Serialize`, name: t`Serialize`,
tooltip: t`Serialize stock`, tooltip: t`Serialize stock`,
hidden: serialized || stockitem?.part_detail?.trackable != true, hidden:
!inStock ||
serialized ||
stockitem?.part_detail?.trackable != true,
icon: <InvenTreeIcon icon="serial" iconProps={{ color: 'blue' }} />, icon: <InvenTreeIcon icon="serial" iconProps={{ color: 'blue' }} />,
onClick: () => { onClick: () => {
serializeStockItem.open(); serializeStockItem.open();
@ -698,6 +701,7 @@ export default function StockDetail() {
{ {
name: t`Transfer`, name: t`Transfer`,
tooltip: t`Transfer Stock`, tooltip: t`Transfer Stock`,
hidden: !inStock,
icon: ( icon: (
<InvenTreeIcon icon="transfer" iconProps={{ color: 'blue' }} /> <InvenTreeIcon icon="transfer" iconProps={{ color: 'blue' }} />
), ),
@ -708,7 +712,7 @@ export default function StockDetail() {
{ {
name: t`Return`, name: t`Return`,
tooltip: t`Return from customer`, tooltip: t`Return from customer`,
hidden: !stockitem.customer, hidden: !stockitem.sales_order,
icon: ( icon: (
<InvenTreeIcon <InvenTreeIcon
icon="return_orders" icon="return_orders"

View File

@ -111,3 +111,49 @@ test('Stock - Serial Numbers', async ({ page }) => {
// Close the form // Close the form
await page.getByRole('button', { name: 'Cancel' }).click(); await page.getByRole('button', { name: 'Cancel' }).click();
}); });
/**
* Test various 'actions' on the stock detail page
*/
test('Stock - Stock Actions', async ({ page }) => {
await doQuickLogin(page);
// Find an in-stock, untracked item
await page.goto(
`${baseUrl}/stock/location/index/stock-items?in_stock=1&serialized=0`
);
await page.getByText('530470210').first().click();
await page
.locator('div')
.filter({ hasText: /^Quantity: 270$/ })
.first()
.waitFor();
// Check for expected action sections
await page.getByLabel('action-menu-barcode-actions').click();
await page.getByLabel('action-menu-barcode-actions-link-barcode').click();
await page.getByRole('banner').getByRole('button').click();
await page.getByLabel('action-menu-printing-actions').click();
await page.getByLabel('action-menu-printing-actions-print-labels').click();
await page.getByRole('button', { name: 'Cancel' }).click();
await page.getByLabel('action-menu-stock-operations').click();
await page.getByLabel('action-menu-stock-operations-count').waitFor();
await page.getByLabel('action-menu-stock-operations-add').waitFor();
await page.getByLabel('action-menu-stock-operations-remove').waitFor();
await page.getByLabel('action-menu-stock-operations-transfer').click();
await page.getByLabel('text-field-notes').fill('test notes');
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByText('This field is required.').first().waitFor();
await page.getByRole('button', { name: 'Cancel' }).click();
// Find an item which has been sent to a customer
await page.goto(`${baseUrl}/stock/item/1012/details`);
await page.getByText('Batch Code: 2022-11-12').waitFor();
await page.getByText('Unavailable').waitFor();
await page.getByLabel('action-menu-stock-operations').click();
await page.getByLabel('action-menu-stock-operations-return').click();
await page.waitForTimeout(2500);
});