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: cad model upload

Brad Barbinbef3630f813a
diff --git a/apps/erp/app/routes/api+/model.upload.ts b/apps/erp/app/routes/api+/model.upload.ts
index 4a49f1d178..e4540ed6b7 100644
--- a/apps/erp/app/routes/api+/model.upload.ts
+++ b/apps/erp/app/routes/api+/model.upload.ts
@@ -33,11 +33,26 @@ export async function action({ request }: ActionFunctionArgs) {
throw new Error("Model path is required");
}
+ const modelRecord = await client.from("modelUpload").insert({
+ id: modelId,
+ modelPath,
+ name,
+ size,
+ companyId,
+ createdBy: userId,
+ });
+
+ if (modelRecord.error) {
+ throw new Error("Failed to record upload: " + modelRecord.error.message);
+ }
+
if (itemId) {
- await client
+ const result = await client
.from("item")
.update({ modelUploadId: modelId })
.eq("id", itemId);
+
+ console.log(result);
}
if (salesRfqLineId) {
await client
@@ -61,19 +76,6 @@ export async function action({ request }: ActionFunctionArgs) {
await client.from("job").update({ modelUploadId: modelId }).eq("id", jobId);
}
- const modelRecord = await client.from("modelUpload").insert({
- id: modelId,
- modelPath,
- name,
- size,
- companyId,
- createdBy: userId,
- });
-
- if (modelRecord.error) {
- throw new Error("Failed to record upload: " + modelRecord.error.message);
- }
-
await tasks.trigger<typeof modelThumbnailTask>("model-thumbnail", {
companyId,
modelId,