Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

Fix picking list line UI

Gaurav Bhatt139e4121f2e0
diff --git a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx
index b9c93812aa..6e4408f1f2 100644
--- a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx
+++ b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx
@@ -292,12 +292,17 @@ function PickingListLineItem({
return (
<div
className={cn(
- "flex items-center justify-between gap-6 p-4 border-b transition-opacity duration-150",
- isLast && "border-none",
- isResolved && "opacity-50 hover:opacity-100"
+ "group flex items-center justify-between gap-6 p-4 border-b",
+ isLast && "border-none"
)}
>
- <HStack spacing={4} className="min-w-0 flex-1">
+ <HStack
+ spacing={4}
+ className={cn(
+ "min-w-0 flex-1 transition-opacity duration-150",
+ isResolved && "opacity-50 group-hover:opacity-100"
+ )}
+ >
<ItemThumbnail
size="md"
thumbnailPath={null}
@@ -338,28 +343,16 @@ function PickingListLineItem({
) : null}
{isTracked ? (
<Badge
- className={cn(
- "text-white text-base tabular-nums",
- isPicked
- ? "bg-emerald-600"
- : quantityPicked > 0
- ? "bg-orange-500"
- : "bg-red-600"
- )}
+ variant={isPicked ? "green" : quantityPicked > 0 ? "orange" : "red"}
+ className="text-base tabular-nums"
>
{quantityPicked}/{quantityToPick}
</Badge>
) : (
<Count
count={isShort ? quantityPicked : quantityToPick}
- className={cn(
- "text-white text-base tabular-nums",
- isPicked
- ? "bg-emerald-600"
- : isShort
- ? "bg-orange-500"
- : "bg-red-600"
- )}
+ variant={isPicked ? "green" : isShort ? "orange" : "red"}
+ className="text-base tabular-nums"
/>
)}
{isLocked ? null : isTracked ? (
diff --git a/apps/mes/app/routes/x+/picking.$pickingListId.tsx b/apps/mes/app/routes/x+/picking.$pickingListId.tsx
index 6714ba4e0b..4116e5ba50 100644
--- a/apps/mes/app/routes/x+/picking.$pickingListId.tsx
+++ b/apps/mes/app/routes/x+/picking.$pickingListId.tsx
@@ -368,12 +368,17 @@ function PickLineItem({
return (
<div
className={cn(
- "flex items-center justify-between gap-6 p-4 border-b transition-opacity duration-150",
- isLast && "border-none",
- isResolved && "opacity-50 hover:opacity-100"
+ "group flex items-center justify-between gap-6 p-4 border-b",
+ isLast && "border-none"
)}
>
- <HStack spacing={4} className="min-w-0 flex-1">
+ <HStack
+ spacing={4}
+ className={cn(
+ "min-w-0 flex-1 transition-opacity duration-150",
+ isResolved && "opacity-50 group-hover:opacity-100"
+ )}
+ >
<ItemThumbnail
size="lg"
thumbnailPath={null}
@@ -414,28 +419,18 @@ function PickLineItem({
) : null}
{isTracked ? (
<Badge
- className={cn(
- "text-white text-base tabular-nums",
- isFullyPicked
- ? "bg-emerald-600"
- : quantityPicked > 0
- ? "bg-orange-500"
- : "bg-red-600"
- )}
+ variant={
+ isFullyPicked ? "green" : quantityPicked > 0 ? "orange" : "red"
+ }
+ className="text-base tabular-nums"
>
{quantityPicked}/{quantityToPick}
</Badge>
) : (
<Count
count={isShort ? quantityPicked : quantityToPick}
- className={cn(
- "text-white text-base tabular-nums",
- isFullyPicked
- ? "bg-emerald-600"
- : isShort
- ? "bg-orange-500"
- : "bg-red-600"
- )}
+ variant={isFullyPicked ? "green" : isShort ? "orange" : "red"}
+ className="text-base tabular-nums"
/>
)}
{isLocked ? (
diff --git a/packages/database/supabase/migrations/20260616134752_picking-list-short-blocks-completion.sql b/packages/database/supabase/migrations/20260616134752_picking-list-short-blocks-completion.sql
new file mode 100644
index 0000000000..0750681668
--- /dev/null
+++ b/packages/database/supabase/migrations/20260616134752_picking-list-short-blocks-completion.sql
@@ -0,0 +1,54 @@
+-- ============================================================================
+-- Fix: a Short line must NOT auto-complete (and lock) a picking list.
+--
+-- Previously `update_picking_list_status` treated a line marked Short as fully
+-- "resolved", so once every other line was picked the header jumped to
+-- Completed — even with an unresolved shortage. This bit hardest after a
+-- reopen (header → Draft, lines still resolved): picking a single item slammed
+-- the list back to Completed and re-locked it.
+--
+-- Now an outstanding Short line keeps the list In Progress. Cancelled lines are
+-- still terminal (the requirement is gone). The list completes via the explicit
+-- Complete button — so a shortage is always acknowledged by a human, never
+-- silently finalized.
+-- ============================================================================
+
+CREATE OR REPLACE FUNCTION update_picking_list_status()
+RETURNS TRIGGER AS $$
+BEGIN
+ -- Only react to picked-quantity or status changes
+ IF (OLD."quantityPicked" IS DISTINCT FROM NEW."quantityPicked")
+ OR (OLD."status" IS DISTINCT FROM NEW."status") THEN
+
+ IF NOT EXISTS (
+ -- no line still outstanding (fully picked, or Cancelled). A Short line
+ -- that isn't fully picked still counts as outstanding work.
+ SELECT 1 FROM "pickingListLine"
+ WHERE "pickingListId" = NEW."pickingListId"
+ AND "status" <> 'Cancelled'
+ AND ("quantityPicked" IS NULL OR "quantityPicked" < "quantityToPick")
+ ) THEN
+ -- All lines resolved → Completed (never override a Cancelled header).
+ UPDATE "pickingList"
+ SET "status" = 'Completed'
+ WHERE "id" = NEW."pickingListId"
+ AND "status" <> 'Cancelled';
+ ELSE
+ -- Work remains: never leave the header stuck on Completed (e.g. after an
+ -- unpick), and move a still-Draft list to In Progress on first progress.
+ UPDATE "pickingList"
+ SET "status" = 'In Progress'
+ WHERE "id" = NEW."pickingListId"
+ AND ("status" = 'Completed'
+ OR ("status" = 'Draft' AND EXISTS (
+ SELECT 1 FROM "pickingListLine"
+ WHERE "pickingListId" = NEW."pickingListId"
+ AND (COALESCE("quantityPicked", 0) > 0
+ OR "status" IN ('Picked', 'Short', 'Cancelled'))
+ )));
+ END IF;
+ END IF;
+
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;