Skip to main content

PurchaseOrderLoad

Purchase order headers. Each PO references an organization (via organization_unit_code) and a supplier (via supplier_code). Lines are a separate object — see purchase_order_line.md.

Import

from lib.objects.purchase_order import PurchaseOrderLoad

Standard BaseLoad methods

See baseload.md.

PurchaseOrder fields

FieldRequiredNotes
id(assigned)UUID
po_numberyesThe customer-facing PO identifier. Not the upsert key — see source_document_id.
po_dateISO date string
organization_unit_codeyesReferences organization.code
supplier_codeyesReferences supplier.supplier_number
supplier_location_code
buyerFree-form (email, name, etc.)
requesterFree-form
statusFree-form (OPEN, CLOSED, APPROVED, ...)
currency_code3-letter ISO
expected_delivery_date
comments
net_amount / tax_amount / gross_amountfloats
sourceOptional free-form source tag
source_document_idyesUpsert key — the API conflicts on this column alone. Lines reference the same source_document_id to hang off this PO.
source_systemyesThe external system the PO came from (e.g. SAP, NETSUITE). Required at the API layer but not part of the upsert key.
is_deletedSoft-delete flag. PO/PO-line/receipt support soft-delete only — there is no is_active / deactivate path.
custom_text_1..15text
custom_number_1..15numeric
custom_date_1..15ISO date

Save order

When importing PO + lines + receipts together, save in this order:

  1. Organizations — referenced by PO header
  2. Suppliers — referenced by PO header
  3. Purchase orders — references org + supplier
  4. PO lines — references the PO via source_document_id + source_line_id
  5. Receipts — references PO + line

Example

from lib.objects.purchase_order import PurchaseOrderLoad

def run(context):
load = PurchaseOrderLoad(context)

po = load.new()
po.po_number = 'PO-2026-0042'
po.po_date = '2026-04-25'
po.organization_unit_code = 'EMEA'
po.supplier_code = 'SUP-100'
po.currency_code = 'EUR'
po.net_amount = 1500.00
po.tax_amount = 315.00
po.gross_amount = 1815.00
po.source_document_id = 'ERP-PO-42'
po.source_system = 'SAP'
po.custom_text_1 = 'priority'
po.custom_number_1 = 30 # e.g. payment terms, days
po.custom_date_1 = '2026-05-31' # e.g. customer-specific cutoff

load.save_all()
return {'created': 1}
# All open POs for a supplier
for po in load.search(supplier_code='SUP-100', status='OPEN'):
print(po.po_number, po.gross_amount)