Skip to content
ERPForAll DocsDevelopment

    Countries, Federal States, and Country Groups

    The base addon supplies res.country, res.country.state, and res.country.group.

    Country records represent sovereign nations or autonomous territories.

    • name: Required country name (e.g. “Indonesia”, “United States”).
    • code: Required, unique 2-letter uppercase ISO 3166-1 alpha-2 code (e.g. “ID”, “US”). Lowercase inputs are sanitized to uppercase on create and write.
    • address_format: Report address presentation template string, defaulting to: '%(street)s\n%(street2)s\n%(city)s %(state_code)s %(zip)s\n%(country_name)s'.
    • currency_id: Foreign key to res.currency.
    • phone_code: International telephone dialing prefix integer.
    • country_group_ids: Many-to-many relationship linking member res.country.group records.
    • state_ids: One-to-many relationship linking subdivision res.country.state records.

    The helper method get_address_fields extracts all interpolation field placeholders from address_format.

    Federal states represent first-level administrative subdivisions of countries (states, provinces, cantons).

    • country_id: Required many-to-one link to res.country (indexed, ondelete restrict).
    • name: Required state name (e.g. “California”, “West Java”).
    • code: State code, unique per country (unique (country_id, code)).

    Country groups represent trade, tax, or regional country clusters (such as “EU”, “SEPA”, “GCC”).

    • name: Group name.
    • code: Optional unique uppercase code.
    • country_ids: Many-to-many link to constituent countries.

    res.partner integrates geographic addressing via:

    • country_id: Many-to-one to res.country.
    • state_id: Many-to-one to res.country.state, dynamically filtered by the partner’s country_id.
    • country_code: Related read-only ISO code from country_id.code.
    • _address_fields: Address propagation includes state_id and country_id. Contact children automatically synchronize their country and state with their parent company address.