Website Snippet Country Code Dropdown
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.0Adds 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).
Depends on
Required by other modules
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-03Confirmation status: 6 confirmed, 3 with no information of 9 versions.
Sources · Odoo 15.0
Confirmed on 2026-11-03 in branch 15.0 of OCA/website.
terminal Installation and usage
OCA documentation · Odoo 18.0Usage
Source · Odoo 18.0To 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_countryvariable. - Extract it from the first 2 letters of the
default_valuevariable. - 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_fieldto give it a name. Usually it will match the field name.default_valuefor thecomplete_field.countriesas ares.countryORM recordset.default_countryas ares.countryrecord.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.
Installation instructions, the distribution package, dependencies and configuration steps are not shown because they have not yet been verified in the module documentation for any version.
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.