This page lists the reference data of the parties module: countries, address levels, and address-level values in src/cluster_erp/modules/parties/settings/, and how each is seeded. These tables are what lets an address follow the structure of any country without code changes. Channel types are also reference data of this module; they are listed on communication channels.
Scope and source¶
- Defined in:
src/cluster_erp/modules/parties/settings/models.py(Country,AddressLevel,AddressLevelValue),services.py(CountryService,AddressLevelService,AddressLevelValueService),routes.py,seed_data.py(ADDRESS_LEVEL_TEMPLATES),metadata.py(COUNTRY_META,ADDRESS_LEVEL_META,ADDRESS_LEVEL_VALUE_META,CHANNEL_TYPE_META). - Count: 3 tables; 18 routes (
@router.decorators inroutes.py); address-level templates for 43 countries (top-level keys ofADDRESS_LEVEL_TEMPLATES). - On the web, these tables are the tabs
country,address_level, andchannel_typeof the Settings section of the parties app (src/cluster_erp/modules/parties/module.py:627-637). The settings view is described on generic tree and settings.
Countries¶
| Name | Type | Meaning | Source |
|---|---|---|---|
code |
String(2) |
ISO 3166 alpha-2 code; unique among live rows | src/cluster_erp/modules/parties/settings/models.py:22-27, src/cluster_erp/modules/parties/settings/models.py:36 |
code_alpha3 |
String(3) |
Alpha-3 code; unique among live rows | src/cluster_erp/modules/parties/settings/models.py:16-21, src/cluster_erp/modules/parties/settings/models.py:37 |
numeric_code |
String(3) |
Numeric code; unique among live rows | src/cluster_erp/modules/parties/settings/models.py:28-33, src/cluster_erp/modules/parties/settings/models.py:38 |
name, native_name |
String(100) |
Common name and official name | src/cluster_erp/modules/parties/settings/models.py:39-40 |
translations |
JSON | Names per language | src/cluster_erp/modules/parties/settings/models.py:41 |
phone_code |
String(10) |
Calling code | src/cluster_erp/modules/parties/settings/models.py:42 |
is_active |
bool | Active flag | src/cluster_erp/modules/parties/settings/models.py:43 |
At every start, seed_iso_countries adds every ISO 3166 country from the pycountry package that is not yet present, using the common name and the official name. It never changes an existing row and leaves phone_code empty; the docstring states that pycountry does not carry calling codes (src/cluster_erp/modules/parties/module.py:44-61, src/cluster_erp/modules/parties/settings/services.py:38-86). The action Update from Internet calls fetch_from_internet, which reads the same bundled pycountry data. It updates the codes and names of existing countries and adds missing ones (src/cluster_erp/modules/parties/settings/services.py:102-139). The list returns a display_name in the request language, resolved from translations (src/cluster_erp/modules/parties/settings/routes.py:38-52). Other modules look a country up by alpha-2 or alpha-3 code with GetCountryByCode (src/cluster_erp/modules/parties/module.py:271-301).
Address levels¶
| Name | Type | Meaning | Source |
|---|---|---|---|
code |
String(20), unique |
Business key from sequence address_level |
src/cluster_erp/modules/parties/settings/models.py:64, src/cluster_erp/modules/parties/settings/services.py:204 |
country_id |
FK to parties_countries.id |
Country | src/cluster_erp/modules/parties/settings/models.py:65-69 |
level_order |
int | Position from the top level down; unique per country among live rows | src/cluster_erp/modules/parties/settings/models.py:54-62, src/cluster_erp/modules/parties/settings/models.py:70 |
name, name_en, translations |
strings, JSON | Level name, English name, and names per language | src/cluster_erp/modules/parties/settings/models.py:71-73 |
is_required |
bool | Whether an address must name this level | src/cluster_erp/modules/parties/settings/models.py:74 |
The action Seed Address Levels creates the levels of one country from ADDRESS_LEVEL_TEMPLATES (src/cluster_erp/modules/parties/settings/routes.py:133-146, src/cluster_erp/modules/parties/settings/services.py:239-282). If the country already has levels, it only adds missing translations from the template. If no template exists for the country code, it creates nothing and says so. The template for TR, for example, has four levels: province, district, neighbourhood, and postal code, the last one optional (src/cluster_erp/modules/parties/settings/seed_data.py:6-11).
Address-level values¶
| Name | Type | Meaning | Source |
|---|---|---|---|
code |
String(20), unique |
Business key from sequence address_level_value |
src/cluster_erp/modules/parties/settings/models.py:96, src/cluster_erp/modules/parties/settings/services.py:313 |
level_id |
FK to parties_address_levels.id |
Level | src/cluster_erp/modules/parties/settings/models.py:97-101 |
parent_id |
FK to parties_address_level_values.id |
Value of the level above, for example the province of a district | src/cluster_erp/modules/parties/settings/models.py:102-105 |
value |
String(255) |
The value | src/cluster_erp/modules/parties/settings/models.py:106 |
postal_code |
String(20) |
Postal code of the value | src/cluster_erp/modules/parties/settings/models.py:107 |
A value is unique per level, text, and parent among live rows (src/cluster_erp/modules/parties/settings/models.py:85-94). GET /settings/address-levels/{level_id}/values lists a level's values sorted by text, optionally filtered by parent_id, which lets a form offer only the districts of the chosen province (src/cluster_erp/modules/parties/settings/routes.py:223-235, src/cluster_erp/modules/parties/settings/services.py:289-302).
Routes¶
All paths are under /api/v1/parties/settings.
| Method and path | Permission | Source |
|---|---|---|
GET /countries/, GET /countries/{country_id} |
country.read |
src/cluster_erp/modules/parties/settings/routes.py:38-52, src/cluster_erp/modules/parties/settings/routes.py:79-89 |
POST /countries/update-from-internet |
country.create |
src/cluster_erp/modules/parties/settings/routes.py:55-62 |
POST /countries/ |
country.create |
src/cluster_erp/modules/parties/settings/routes.py:65-76 |
PUT /countries/{country_id} |
country.update |
src/cluster_erp/modules/parties/settings/routes.py:92-103 |
POST /countries/bulk-delete, DELETE /countries/{country_id} |
country.bulk_delete, country.delete |
src/cluster_erp/modules/parties/settings/routes.py:106-125 |
POST /countries/{country_id}/seed-address-levels |
country.seed |
src/cluster_erp/modules/parties/settings/routes.py:133-146 |
GET /countries/{country_id}/address-levels |
address_level.read |
src/cluster_erp/modules/parties/settings/routes.py:154-168 |
POST /address-levels, PUT /address-levels/{level_id} |
address_level.create, address_level.update |
src/cluster_erp/modules/parties/settings/routes.py:171-193 |
POST /address-levels/bulk-delete, DELETE /address-levels/{level_id} |
address_level.bulk_delete, address_level.delete |
src/cluster_erp/modules/parties/settings/routes.py:196-215 |
GET /address-levels/{level_id}/values |
address_level_value.read |
src/cluster_erp/modules/parties/settings/routes.py:223-235 |
POST /address-level-values, PUT /address-level-values/{value_id} |
address_level_value.create, address_level_value.update |
src/cluster_erp/modules/parties/settings/routes.py:238-263 |
POST /address-level-values/bulk-delete, DELETE /address-level-values/{value_id} |
address_level_value.bulk_delete, address_level_value.delete |
src/cluster_erp/modules/parties/settings/routes.py:266-285 |
Constraints and validation¶
- Creating a country with a code that a live country already has answers a conflict (
src/cluster_erp/modules/parties/settings/routes.py:72-74). - Country codes are stored in upper case (
src/cluster_erp/modules/parties/settings/services.py:141-153). - Deleting a country, level, or value sets
deleted_at; nothing is removed (src/cluster_erp/modules/parties/settings/services.py:166-177).
Discrepancies¶
Terms introduced¶
| Term | Code identifier | Definition | Turkish term | Source |
|---|---|---|---|---|
| country | Country |
An ISO 3166 country row used by addresses and other modules. | Ülke | src/cluster_erp/modules/parties/settings/models.py:12 |
| address level | AddressLevel |
One level of a country's address hierarchy, such as province or district. | Adres seviyesi | src/cluster_erp/modules/parties/settings/models.py:52 |
| address-level value | AddressLevelValue |
One allowed value at an address level, linked to its parent value. | Adres seviyesi değeri | src/cluster_erp/modules/parties/settings/models.py:83 |
Related pages¶
Verified against commit 92f8051 on 2026-11-13.