mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-03 15:52:51 +00:00
[UI] Consume tracked (#10422)
* Prevent manual consumption of tracked stock * Prevent manual consuming of trackable items
This commit is contained in:
@@ -183,9 +183,13 @@ export default function BuildAllocatedStockTable({
|
||||
|
||||
const [selectedItems, setSelectedItems] = useState<any[]>([]);
|
||||
|
||||
const itemsToConsume = useMemo(() => {
|
||||
return selectedItems.filter((item) => !item.part_detail?.trackable);
|
||||
}, [selectedItems]);
|
||||
|
||||
const consumeStock = useConsumeBuildItemsForm({
|
||||
buildId: buildId ?? 0,
|
||||
allocatedItems: selectedItems,
|
||||
allocatedItems: itemsToConsume,
|
||||
onFormSuccess: () => {
|
||||
table.clearSelectedRecords();
|
||||
table.refreshTable();
|
||||
@@ -225,13 +229,16 @@ export default function BuildAllocatedStockTable({
|
||||
|
||||
const rowActions = useCallback(
|
||||
(record: any): RowAction[] => {
|
||||
const part = record.part_detail ?? {};
|
||||
const trackable: boolean = part?.trackable ?? false;
|
||||
|
||||
return [
|
||||
{
|
||||
color: 'green',
|
||||
icon: <IconCircleDashedCheck />,
|
||||
title: t`Consume`,
|
||||
tooltip: t`Consume Stock`,
|
||||
hidden: !buildId || !user.hasChangeRole(UserRoles.build),
|
||||
hidden: !buildId || trackable || !user.hasChangeRole(UserRoles.build),
|
||||
onClick: () => {
|
||||
setSelectedItems([record]);
|
||||
consumeStock.open();
|
||||
|
@@ -665,9 +665,10 @@ export default function BuildLineTable({
|
||||
(record: any): RowAction[] => {
|
||||
const part = record.part_detail ?? {};
|
||||
const in_production = build.status == buildStatus.PRODUCTION;
|
||||
const consumable = record.bom_item_detail?.consumable ?? false;
|
||||
const consumable: boolean = record.bom_item_detail?.consumable ?? false;
|
||||
const trackable: boolean = part?.trackable ?? false;
|
||||
|
||||
const hasOutput = !!output?.pk;
|
||||
const hasOutput: boolean = !!output?.pk;
|
||||
|
||||
const required = Math.max(
|
||||
0,
|
||||
@@ -678,6 +679,7 @@ export default function BuildLineTable({
|
||||
const canConsume =
|
||||
in_production &&
|
||||
!consumable &&
|
||||
!trackable &&
|
||||
record.allocated > 0 &&
|
||||
user.hasChangeRole(UserRoles.build);
|
||||
|
||||
|
Reference in New Issue
Block a user