Skip to main content

OrganizationLoad

Organization units (groups, companies, departments). Has two child types: identifiers (VAT number, DUNS, EIN) and addresses.

Organization
├── identifiers[]
└── addresses[]

Import​

from lib.objects.organization import OrganizationLoad

Standard BaseLoad methods​

get_all(), search(), new(), save_all(), patch_all(), delete_keys(), index_by_source(), obj.save(), obj.deactivate() (PATCHes active to false), obj.delete(). See BaseLoad.

Keys​

A unit is found by its Nuntiq id, by source_system + source_record_id, or by code. Identifiers are matched by id, source key, or identifier_type + identifier_value; addresses by id, source key, or the address itself.

Organization fields​

FieldRequiredNotes
id(assigned)The Nuntiq id, a UUID string
nameyes
codeyes, unless source_record_id is setNatural key. A unit with a source identity can be created without a code; a consultant assigns it later
organization_typeyes1 = Group, 2 = Company, 3 = Department. A Company may have a Group parent, a Department must have a Company parent
parent_idThe parent's Nuntiq id (UUID). Returned on read, accepted on save
parent_codeSave only: the parent's code instead of its id, an existing unit or one in the same request. Reads do not return it
active / active_from / active_toactive defaults to true
default_currency3-letter ISO code, stored upper case
timezoneIANA time zone, e.g. Europe/Amsterdam. Kept when a save leaves it out, so a unit's time zone set in the portal survives your saves
source_system / source_record_id / source_updated_atExternal identity, as on every engine resource
custom_field_1..15Fifteen user-defined slots

OrganizationIdentifier fields​

FieldRequired
id(assigned) UUID string
identifier_labelyes
identifier_valueyes
identifier_typeyes. Stored upper case; common values: VAT, DUNS, EIN, LEI
source_system / source_record_id / source_updated_at

OrganizationAddress fields​

id (UUID string), name, street (required), city (required), state, postal_code, country_code (required, stored upper case), source_system, source_record_id, source_updated_at, custom_field_1..5.

Example​

from lib.objects.organization import OrganizationLoad

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

group = load.new()
group.name = 'Acme Group'
group.code = 'ACME'
group.organization_type = 1
group.source_record_id = 'ORG-1'

org = load.new()
org.name = 'Acme EMEA BV'
org.code = 'ACME-EMEA'
org.organization_type = 2 # 1 Group, 2 Company, 3 Department
org.parent_code = 'ACME' # the group above, same request
org.default_currency = 'EUR'
org.source_record_id = 'ORG-2'

vat = org.new_identifier()
vat.identifier_label = 'VAT Number'
vat.identifier_value = 'NL123456789B01'
vat.identifier_type = 'VAT'

addr = org.new_address()
addr.street = 'Herengracht 500'
addr.city = 'Amsterdam'
addr.country_code = 'NL'

results = load.save_all()
return {'saved': len(results)}

Units people also edit​

Organization units are often maintained by hand in the portal too. To change only the fields your system owns, read, change and save:

units = load.index_by_source('MY_ERP') # your connector's source system
for ext in fetch_companies():
unit = units.get(ext['id'])
if unit:
unit.name = ext['name']
unit.save() # sends the record as read, with your change

Or send only those fields with patch_all():

load.patch_all([{'source_record_id': ext['id'], 'name': ext['name']} for ext in fetch_companies()])

Exact-match filters: code, organization_type, active, source_system, source_record_id, plus updated_since and include_deleted.

Delete​

load.delete_keys([{'code': 'ACME-OLD'}])

Soft delete, your own units only. A unit with live children cannot be deleted. To keep a unit but switch it off, call unit.deactivate().

When to save organizations vs suppliers​

Suppliers and purchase orders reference organizations by code. Save organizations before suppliers in the same connector run.