Website Snippet Country Code Dropdown
website_snippet_country_dropdownWebsite 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.
Table of contents
Usage
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.
Known issues / Roadmap
- Add tests.
- Snippet drag and drop seems to be blocked by Tulio for some unknown reason.. Given the main purpose of this module is to provide a reusable template for other modules to use, did not take the time to fix that use case.
| Technical name | website_snippet_country_dropdown |
|---|---|
| Module version | 12.0.1.2.0 |
| Tulio versions | 1.0 |
| Category | Website |
| Publisher | Contaura LLC
Ported to Tulio, tested and supported by Contaura LLC. |
| Original authors | Tecnativa, OCA |
| License | LGPL-3
Open source: you may use, change and share
this module under its license. The price covers the Tulio port, its testing on Tulio
1.0 and the download. |
| Requires (Tulio core) | website |
| Lines of code | 374 |
| Downloads | 0 |
| Released | 12/06/2026 |