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(production): show model thumbnails on batch screens (#2037)

BettrCallRaul171a8e232078
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index 68cf542183..6939908640 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -7050,7 +7050,7 @@ export async function getJobOperationBatchMembers(
const result = await client
.from("jobOperation")
.select(
- "id, jobOperationBatchId, operationQuantity, quantityComplete, quantityScrapped, job(id, jobId), jobMakeMethod(item(readableIdWithRevision, name, thumbnailPath))"
+ "id, jobOperationBatchId, operationQuantity, quantityComplete, quantityScrapped, job(id, jobId), jobMakeMethod(item(readableIdWithRevision, name, thumbnailPath, modelUpload(thumbnailPath)))"
)
.in("jobOperationBatchId", batchIds)
.eq("companyId", companyId);
@@ -7064,7 +7064,10 @@ export async function getJobOperationBatchMembers(
jobReadableId: op.job?.jobId ?? null,
itemReadableId: op.jobMakeMethod?.item?.readableIdWithRevision ?? null,
itemName: op.jobMakeMethod?.item?.name ?? null,
- thumbnailPath: op.jobMakeMethod?.item?.thumbnailPath ?? null,
+ thumbnailPath:
+ op.jobMakeMethod?.item?.thumbnailPath ??
+ op.jobMakeMethod?.item?.modelUpload?.thumbnailPath ??
+ null,
operationQuantity: op.operationQuantity ?? 0,
quantityComplete: op.quantityComplete ?? 0,
quantityScrapped: op.quantityScrapped ?? 0
@@ -7132,7 +7135,7 @@ export async function getJobOperationBatchWithMembers(
const members = await client
.from("jobOperation")
.select(
- "id, description, operationQuantity, quantityComplete, quantityScrapped, status, setupTime, setupUnit, laborTime, laborUnit, machineTime, machineUnit, workCenter(name), job(id, jobId, customerId, salesOrderId, status), jobMakeMethod(item(readableIdWithRevision, name, thumbnailPath))"
+ "id, description, operationQuantity, quantityComplete, quantityScrapped, status, setupTime, setupUnit, laborTime, laborUnit, machineTime, machineUnit, workCenter(name), job(id, jobId, customerId, salesOrderId, status), jobMakeMethod(item(readableIdWithRevision, name, thumbnailPath, modelUpload(thumbnailPath)))"
)
.eq("jobOperationBatchId", batchId)
.eq("companyId", companyId);
diff --git a/apps/erp/app/modules/production/ui/Batches/BatchDetailDrawer.tsx b/apps/erp/app/modules/production/ui/Batches/BatchDetailDrawer.tsx
index 427d287dc6..8e2f6b5c09 100644
--- a/apps/erp/app/modules/production/ui/Batches/BatchDetailDrawer.tsx
+++ b/apps/erp/app/modules/production/ui/Batches/BatchDetailDrawer.tsx
@@ -450,6 +450,8 @@ export function BatchDetailDrawer({
<ItemThumbnail
thumbnailPath={
member.jobMakeMethod?.item?.thumbnailPath ??
+ member.jobMakeMethod?.item?.modelUpload
+ ?.thumbnailPath ??
null
}
type="Part"
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
index 6cc51f0094..022e66aea6 100644
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
@@ -750,7 +750,7 @@
{"name":"production_getJobOperationBatchEvents","classification":"READ","schema":"1a62d6c430a5","response":"031cdafdafbd","permission":"production:view","paginates":false},
{"name":"production_getJobOperationBatchMembers","classification":"READ","schema":"d429e4a46057","response":"66bcdc105c00","permission":"production:view","paginates":false},
{"name":"production_getJobOperationBatchMemberStats","classification":"READ","schema":"d429e4a46057","response":"03aaee65a70b","permission":"production:view","paginates":false},
- {"name":"production_getJobOperationBatchWithMembers","classification":"READ","schema":"1a62d6c430a5","response":"520bac578dba","permission":"production:view","paginates":false},
+ {"name":"production_getJobOperationBatchWithMembers","classification":"READ","schema":"1a62d6c430a5","response":"0cbc9a774c45","permission":"production:view","paginates":false},
{"name":"production_getJobOperationDependencies","classification":"READ","schema":"ca49bc65b712","response":"9214ed6d51dd","permission":"production:view","paginates":false},
{"name":"production_getJobOperations","classification":"READ","schema":"f67274205e12","response":"7f24f7881568","permission":"production:view","paginates":true},
{"name":"production_getJobOperationsByMethodId","classification":"READ","schema":"7679db37b5f9","response":"02e990581d5b","permission":"production:view","paginates":false},
diff --git a/apps/erp/app/routes/api+/production.batchable-operations.ts b/apps/erp/app/routes/api+/production.batchable-operations.ts
index 2ef1217e67..49874850fd 100644
--- a/apps/erp/app/routes/api+/production.batchable-operations.ts
+++ b/apps/erp/app/routes/api+/production.batchable-operations.ts
@@ -123,7 +123,9 @@ export async function loader({ request }: LoaderFunctionArgs) {
// Enrich with the fields the RPC doesn't return but the wizard needs.
// The thumbnail follows the operation's PRODUCED item (r.itemId, the op's
// make-method item resolved by the RPC), not the job's root item — a
- // sub-assembly operation shows its own part, matching its readableId.
+ // sub-assembly operation shows its own part, matching its readableId. An
+ // item with no image of its own falls back to its CAD model's thumbnail, as
+ // the parts list and the batch PDF do.
const [opDetails, itemThumbnails] = await Promise.all([
client
.from("jobOperation")
@@ -137,7 +139,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
.eq("companyId", companyId),
client
.from("item")
- .select("id, thumbnailPath")
+ .select("id, thumbnailPath, modelUpload(thumbnailPath)")
.in("id", [...new Set(rows.map((r) => r.itemId))])
.eq("companyId", companyId)
]);
@@ -146,7 +148,8 @@ export async function loader({ request }: LoaderFunctionArgs) {
);
const thumbnailByItemId = new Map(
(itemThumbnails.data ?? []).map(
- (i) => [i.id, i.thumbnailPath ?? null] as const
+ (i) =>
+ [i.id, i.thumbnailPath ?? i.modelUpload?.thumbnailPath ?? null] as const
)
);