Merge 844e08814f into c56fe7f612
This commit is contained in:
commit
7f50479157
|
|
@ -13,6 +13,7 @@ import {
|
|||
type InstanceRenderInterface,
|
||||
RenderInlineModel
|
||||
} from './Instance';
|
||||
import { StatusRenderer, getStatusCodes } from './StatusRenderer';
|
||||
|
||||
/**
|
||||
* Inline rendering of a single StockLocation instance
|
||||
|
|
@ -102,6 +103,17 @@ export function RenderStockItem(
|
|||
const showLocation: boolean = props.extra?.show_location !== false;
|
||||
const location: any = props.instance?.location_detail;
|
||||
|
||||
const statusKey = instance?.status_custom_key ?? instance?.status;
|
||||
const flaggedStatusNames = ['ATTENTION', 'DAMAGED'];
|
||||
const statusCodes = getStatusCodes(ModelType.stockitem);
|
||||
const showStatus =
|
||||
props.extra?.show_status === true &&
|
||||
!!statusCodes &&
|
||||
Object.values(statusCodes.values).some(
|
||||
(entry) =>
|
||||
entry.key == statusKey && flaggedStatusNames.includes(entry.name)
|
||||
);
|
||||
|
||||
// Form the "secondary" text to display
|
||||
const secondary: ReactNode = (
|
||||
<Group gap='xs' style={{ paddingLeft: '5px' }}>
|
||||
|
|
@ -111,6 +123,9 @@ export function RenderStockItem(
|
|||
{instance.batch && (
|
||||
<InlineSecondaryBadge title={t`Batch`} text={instance.batch} />
|
||||
)}
|
||||
{showStatus && (
|
||||
<StatusRenderer status={statusKey} type={ModelType.stockitem} />
|
||||
)}
|
||||
</Group>
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -587,6 +587,9 @@ function BuildAllocateLineRow({
|
|||
field_type: 'related field',
|
||||
api_url: apiUrl(ApiEndpoints.stock_item_list),
|
||||
model: ModelType.stockitem,
|
||||
modelRenderer: ({ instance }: { instance: any }) => (
|
||||
<RenderStockItem instance={instance} extra={{ show_status: true }} />
|
||||
),
|
||||
autoFill: !output || !!output?.serial,
|
||||
autoFillFilters: {
|
||||
serial: output?.serial
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
|||
import { ModelType } from '@lib/enums/ModelType';
|
||||
import RemoveRowButton from '../components/buttons/RemoveRowButton';
|
||||
import { StandaloneField } from '../components/forms/StandaloneField';
|
||||
import { RenderStockItem } from '../components/render/Stock';
|
||||
|
||||
import { ProgressBar } from '@lib/components/ProgressBar';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
|
|
@ -319,6 +320,9 @@ function SalesOrderAllocateLineRow({
|
|||
field_type: 'related field',
|
||||
api_url: apiUrl(ApiEndpoints.stock_item_list),
|
||||
model: ModelType.stockitem,
|
||||
modelRenderer: ({ instance }: { instance: any }) => (
|
||||
<RenderStockItem instance={instance} extra={{ show_status: true }} />
|
||||
),
|
||||
autoFill: true,
|
||||
filters: {
|
||||
available: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue