OdooWiki OCA HUB

Website Snippet Country Code Dropdown

website_snippet_country_dropdown folder_open OCA/website open_in_new
Website License: LGPL-3

This module adds a snippet with a dropdown and an input text field, is a base for be inherited by others modules into an HTML form.

This can be inserted into form elements.

auto_awesome What this module does

AI-generated from the code · Odoo 18.0

Adds a country dropdown snippet for website forms, letting visitors pick a country flag and code that is combined with a typed number into a single hidden field.

This module gives website builders a ready-made country selector that can be dropped into any HTML form on a website page.

  • The snippet shows a flag button that opens a scrollable list of all countries, a small read-only box with the selected country code, and a text field where the visitor types the rest of the value (for example a VAT or tax number).
  • When a country is chosen, the flag and code update immediately, and the code is automatically joined to whatever is typed in the text field to fill a hidden field that is actually submitted with the form.
  • The starting country is taken from a default value, otherwise from the logged-in user's country, otherwise from the website company's country, otherwise the first country in the list.
  • The snippet can be set as read-only, and the field names, label and placeholder can be configured by the person building the page.
  • Country flag images are loaded only when they become visible in the dropdown, which keeps the page fast.
  • A demo page named "Country dropdown demo" is added to the website menu to try the behaviour, and a guided tour checks that selecting a country and typing text produces the expected submitted values.

The module works on the website front end and uses the country data already stored in Odoo (res.country).

Text generated by AI (DeepSeek) from reading the Odoo 18.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 6 confirmed, 3 with no information of 9 versions.

terminal Installation and usage

OCA documentation · Odoo 18.0

To extend this template you need to inherit country_dropdown template and add your personal code.

The template have three input text:

  • no_country_field: Field without code country.
  • country_code_field: Field with only country code (read only)
  • complete_field: Field with the previous two joined (hidden)

The name of the complete field is customizable when user insert the snippet into a form element with the website editor.

Development

You can call the reusable Qweb template called website_snippet_country_dropdown.country_dropdown in your views to add a sensible country-combined field, ideal for VATs.

The default country will be the first match among:

  • Extract it from the default_country variable.
  • Extract it from the first 2 letters of the default_value variable.
  • The current user's country.
  • The current website's company's country.
  • The first country in the list.

All variables you can use to modify its behavior:

  • complete_field to give it a name. Usually it will match the field name.
  • default_value for the complete_field.
  • countries as a res.country ORM recordset.
  • default_country as a res.country record.
  • no_country_placeholder.

You can view an example in website_sale_checkout_country_vat in OCA/e-commerce.

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.