Skip to main content

Allow to select country in a dropdown

Project description

License: LGPL-3

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.

Usage

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

The template have three input text:

  1. no_country_field: Field without code country.

  2. country_code_field: Field with only country code (read only)

  3. 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:

  1. Extract it from the default_country variable.

  2. Extract it from the first 2 letters of the default_value variable.

  3. The current user’s country.

  4. The current website’s company’s country.

  5. 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.

Try me on Runbot

Known issues / Roadmap

  • Add tests.

  • Flag images should be lazy-loaded to optimize loading.

  • Snippet drag and drop seems to be blocked by Odoo 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.

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.

Credits

Images

  • Odoo Community Association: Icon.

Contributors

Maintainer

Odoo Community Association

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file odoo9_addon_website_snippet_country_dropdown-9.0.1.0.0.99.dev10-py2-none-any.whl.

File metadata

File hashes

Hashes for odoo9_addon_website_snippet_country_dropdown-9.0.1.0.0.99.dev10-py2-none-any.whl
Algorithm Hash digest
SHA256 a4f034e26974e6cff065097dc7a8c67d2877e77be836edf9d675ca08ca8bcea6
MD5 ffc3156be0459f33402ac86154d6312b
BLAKE2b-256 4649adb980ace2080807fdeb7f79361593558b23bbf6e2d180b0b6620617bdbf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page