Skip to content

Commit

Permalink
[8.0][IMP][website_snippet_country_dropdown] Choose user's country by…
Browse files Browse the repository at this point in the history
… default.

With this patch, when the currently logged-in user has a country in its profile, it will be chosen by default for the flag.
  • Loading branch information
yajo committed Jul 6, 2016
1 parent e120b1d commit a4103cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
23 changes: 22 additions & 1 deletion website_snippet_country_dropdown/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,33 @@ The template have three input text:
The name of the complete field is customizable when user insert the snippet
into a form element with the website editor.

You can view an example in https://github.com/OCA/e-commerce/tree/8.0/website_sale_checkout_country_vat.
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.

You can view an example in
https://github.com/OCA/e-commerce/tree/8.0/website_sale_checkout_country_vat.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186/8.0

Known issues / Roadmap
======================

* Add tests.

Bug Tracker
===========

Expand Down
2 changes: 1 addition & 1 deletion website_snippet_country_dropdown/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Website Snippet Country Dropdown Code",
"summary": "Allow to select country in a dropdown",
"version": "8.0.1.0.0",
"version": "8.0.1.1.0",
"category": "Website",
"website": "http://www.tecnativa.com",
"author": "Tecnativa, "
Expand Down
2 changes: 1 addition & 1 deletion website_snippet_country_dropdown/views/snippets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<template id="country_dropdown" name="Country Dropdown">
<t t-set="default_value" t-value="default_value or ''"/>
<t t-set="countries" t-value="request.env['res.country'].search([])"/>
<t t-set="default_country" t-value="default_country or countries.search([('code', '=', default_value[:2])]) or website.company_id.country_id or countries[:1]"/>
<t t-set="default_country" t-value="default_country or countries.search([('code', '=', default_value[:2])]) or request.env.user.country_id or website.company_id.country_id or countries[:1]"/>
<div class="input-group col-md-12 js_country_dropdown" t-ignore="true">
<div class="input-group-btn flag-button">
<button type="button" id="btn_vat_code"
Expand Down

0 comments on commit a4103cb

Please sign in to comment.