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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
Fix paperless parts overwrite
Gaurav Bhatt806f169de206
diff --git a/packages/ee/src/paperless-parts/lib/lib.ts b/packages/ee/src/paperless-parts/lib/lib.tsindex a5b523e591..fde8e133b9 100644--- a/packages/ee/src/paperless-parts/lib/lib.ts+++ b/packages/ee/src/paperless-parts/lib/lib.ts@@ -829,13 +829,10 @@ async function uploadModelFile(}// Link model to sales order line- const [lineUpdate] = await Promise.all([- carbon- .from("salesOrderLine")- .update({ modelUploadId: modelId })- .eq("id", salesOrderLineId),- carbon.from("item").update({ modelUploadId: modelId }).eq("id", itemId)- ]);+ const lineUpdate = await carbon+ .from("salesOrderLine")+ .update({ modelUploadId: modelId })+ .eq("id", salesOrderLineId);if (lineUpdate.error) {console.error(@@ -845,6 +842,21 @@ async function uploadModelFile(return false;}+ // Only update item.modelUploadId if the item doesn't already have a model+ // linked — replacing it would orphan the old modelUpload and its thumbnail+ const existingItem = await carbon+ .from("item")+ .select("modelUploadId")+ .eq("id", itemId)+ .single();++ if (!existingItem.data?.modelUploadId) {+ await carbon+ .from("item")+ .update({ modelUploadId: modelId })+ .eq("id", itemId);+ }+console.log(`Successfully uploaded CAD model ${file.name} and linked to line ${salesOrderLineId}`);