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.

808 B
Raw Blame
-- Purchase orders raised by the planning pages skip the approval rule when the
-- company allows it (on by default).
--
-- "createdFromPlanning" is set only on a PO the planning Order button creates.
-- Any manual line change afterwards — adding, editing or deleting a line on the
-- PO page, the API or MCP (upsertPurchaseOrderLine / deletePurchaseOrderLine) —
-- clears it, so an MRP purchase order cannot be padded to dodge approval.
-- Planning's own writes (its Order button, Apply, the drawer's inline edit)
-- keep it. The finalize route reads both columns.
ALTER TABLE "purchaseOrder"
  ADD COLUMN IF NOT EXISTS "createdFromPlanning" BOOLEAN NOT NULL DEFAULT false;

ALTER TABLE "companySettings"
  ADD COLUMN IF NOT EXISTS "skipApprovalForPlanningPurchaseOrders" BOOLEAN NOT NULL DEFAULT true;