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
| Field | Required | Notes |
|---|---|---|
id | (assigned) | UUID |
po_number | yes | The customer-facing PO identifier. Not the upsert key — see source_document_id. |
po_date | ISO date string | |
organization_unit_code | yes | References organization.code |
supplier_code | yes | References supplier.supplier_number |
supplier_location_code | ||
buyer | Free-form (email, name, etc.) | |
requester | Free-form | |
status | Free-form (OPEN, CLOSED, APPROVED, ...) | |
currency_code | 3-letter ISO | |
expected_delivery_date | ||
comments | ||
net_amount / tax_amount / gross_amount | floats | |
source | Optional free-form source tag | |
source_document_id | yes | Upsert key — the API conflicts on this column alone. Lines reference the same source_document_id to hang off this PO. |
source_system | yes | The external system the PO came from (e.g. SAP, NETSUITE). Required at the API layer but not part of the upsert key. |
is_deleted | Soft-delete flag. PO/PO-line/receipt support soft-delete only — there is no is_active / deactivate path. | |
custom_text_1..15 | text | |
custom_number_1..15 | numeric | |
custom_date_1..15 | ISO date |
Save order
When importing PO + lines + receipts together, save in this order:
- Organizations — referenced by PO header
- Suppliers — referenced by PO header
- Purchase orders — references org + supplier
- PO lines — references the PO via
source_document_id+source_line_id - 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}
Search
# All open POs for a supplier
for po in load.search(supplier_code='SUP-100', status='OPEN'):
print(po.po_number, po.gross_amount)