diff --git a/setup/website_snippet_country_dropdown/odoo/addons/website_snippet_country_dropdown b/setup/website_snippet_country_dropdown/odoo/addons/website_snippet_country_dropdown new file mode 120000 index 0000000000..a4888b0492 --- /dev/null +++ b/setup/website_snippet_country_dropdown/odoo/addons/website_snippet_country_dropdown @@ -0,0 +1 @@ +../../../../website_snippet_country_dropdown \ No newline at end of file diff --git a/setup/website_snippet_country_dropdown/setup.py b/setup/website_snippet_country_dropdown/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/website_snippet_country_dropdown/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_snippet_country_dropdown/README.rst b/website_snippet_country_dropdown/README.rst new file mode 100644 index 0000000000..f3d6aa2f05 --- /dev/null +++ b/website_snippet_country_dropdown/README.rst @@ -0,0 +1,132 @@ +===================================== +Website Snippet Country Code Dropdown +===================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwebsite-lightgray.png?logo=github + :target: https://github.com/OCA/website/tree/15.0/website_snippet_country_dropdown + :alt: OCA/website +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/website-15-0/website-15-0-website_snippet_country_dropdown + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/186/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +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** + +.. contents:: + :local: + +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 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Sergio Teruel + * Jairo Llopis + * Alexandre Díaz + * Carlos Roca + * Ernesto Tejeda + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/website `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_snippet_country_dropdown/__init__.py b/website_snippet_country_dropdown/__init__.py new file mode 100644 index 0000000000..cfab9fc4ae --- /dev/null +++ b/website_snippet_country_dropdown/__init__.py @@ -0,0 +1,2 @@ +# Copyright 2016 Jairo Llopis +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). diff --git a/website_snippet_country_dropdown/__manifest__.py b/website_snippet_country_dropdown/__manifest__.py new file mode 100644 index 0000000000..4ca10828f0 --- /dev/null +++ b/website_snippet_country_dropdown/__manifest__.py @@ -0,0 +1,32 @@ +# Copyright 2016 Sergio Teruel +# Copyright 2016 Jairo Llopis +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Website Snippet Country Code Dropdown", + "summary": "Allow to select country in a dropdown", + "version": "16.0.1.0.0", + "category": "Website", + "website": "https://github.com/OCA/website", + "author": "Tecnativa, " "Odoo Community Association (OCA)", + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": ["website"], + "data": ["views/snippets.xml"], + "demo": ["demo/pages.xml"], + "assets": { + "web.assets_tests": [ + "/website_snippet_country_dropdown/static/src/js/" + "web_tour_country_dropdown.js" + ], + "web.assets_frontend": [ + "/website_snippet_country_dropdown/static/src/css/style.scss", + "/website_snippet_country_dropdown/static/src/js/" + "website_snippet_country_dropdown.js", + ], + "web.assets_qweb": [ + "/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml" + ], + }, +} diff --git a/website_snippet_country_dropdown/demo/pages.xml b/website_snippet_country_dropdown/demo/pages.xml new file mode 100644 index 0000000000..bfa7845579 --- /dev/null +++ b/website_snippet_country_dropdown/demo/pages.xml @@ -0,0 +1,92 @@ + + + + + + True + /website_snippet_country_dropdown.demo_page + + + + Country dropdown demo + /website_snippet_country_dropdown.demo_page + + 50 + + + diff --git a/website_snippet_country_dropdown/i18n/es.po b/website_snippet_country_dropdown/i18n/es.po new file mode 100644 index 0000000000..07703d129e --- /dev/null +++ b/website_snippet_country_dropdown/i18n/es.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_snippet_country_dropdown +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-09 02:51+0000\n" +"PO-Revision-Date: 2020-10-06 17:16+0000\n" +"Last-Translator: claudiagn \n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "A readonly country dropdown input" +msgstr "Una entrada desplegable de país de solo lectura" + +#. module: website_snippet_country_dropdown +#: model:website.menu,name:website_snippet_country_dropdown.country_dropdown_demo_page_link +msgid "Country dropdown demo" +msgstr "Demo del desplegable de países" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Other label" +msgstr "Otra etiqueta" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Submit (you will see the GET parameters in the URL)" +msgstr "Enviar (verá los parámetros GET en la URL)" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Test here the country dropdown snippet behavior" +msgstr "Pruebe aquí el comportamiento del snippet desplegable de países" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "This is a form" +msgstr "Esto es un formulario" + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:0 +#, python-format +msgid "" +"Write the \"name\" attribute for the input what will be sent with the form." +msgstr "" +"Escriba el atributo \"name\" para el campo que se mandará al formulario." + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:0 +#, python-format +msgid "You can modify the label directly with the website editor." +msgstr "Puede modificar la etiqueta directamente desde el editor web." + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.dropdown_element_form +msgid "Your Label" +msgstr "Su etiqueta" diff --git a/website_snippet_country_dropdown/i18n/fr.po b/website_snippet_country_dropdown/i18n/fr.po new file mode 100644 index 0000000000..28e519adb0 --- /dev/null +++ b/website_snippet_country_dropdown/i18n/fr.po @@ -0,0 +1,79 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_snippet_country_dropdown +# +# Translators: +# OCA Transbot , 2017 +# Quentin THEURET , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-25 07:50+0000\n" +"PO-Revision-Date: 2017-07-25 07:50+0000\n" +"Last-Translator: Quentin THEURET , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +#, fuzzy +msgid "A readonly country dropdown input" +msgstr "Testez ici le comportement de la liste déroulante des pays" + +#. module: website_snippet_country_dropdown +#: model:website.menu,name:website_snippet_country_dropdown.country_dropdown_demo_page_link +msgid "Country dropdown demo" +msgstr "Démo de la liste déroulante des pays" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Other label" +msgstr "Autre label" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Submit (you will see the GET parameters in the URL)" +msgstr "Envoyer (vous verrez les paramètres GET dans l'URL)" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Test here the country dropdown snippet behavior" +msgstr "Testez ici le comportement de la liste déroulante des pays" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "This is a form" +msgstr "C'est un formulaire" + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:0 +#, python-format +msgid "" +"Write the \"name\" attribute for the input what will be sent with the form." +msgstr "" +"Saisissez le \"nom\" de l'attribut pour l'entrée qui sera envoyée avec le " +"formulaire." + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:0 +#, python-format +msgid "You can modify the label directly with the website editor." +msgstr "" +"Vous pouvez modifier le libellé directement avec l'éditeur de sites Web." + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.dropdown_element_form +msgid "Your Label" +msgstr "Votre libellé" diff --git a/website_snippet_country_dropdown/i18n/it.po b/website_snippet_country_dropdown/i18n/it.po new file mode 100644 index 0000000000..7186f1dc49 --- /dev/null +++ b/website_snippet_country_dropdown/i18n/it.po @@ -0,0 +1,73 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_snippet_country_dropdown +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-12-27 17:44+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "A readonly country dropdown input" +msgstr "Un inserimento a tendina della nazione in sola lettura" + +#. module: website_snippet_country_dropdown +#: model:website.menu,name:website_snippet_country_dropdown.country_dropdown_demo_page_link +msgid "Country dropdown demo" +msgstr "Dimostrazione tendina nazione" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Other label" +msgstr "Altra etichetta" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Submit (you will see the GET parameters in the URL)" +msgstr "Invio (si vedranno i parametri GET nell'URL)" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Test here the country dropdown snippet behavior" +msgstr "Testare qui il comportamento del codice tendina nazione" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "This is a form" +msgstr "Questo è un modulo" + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:0 +#, python-format +msgid "" +"Write the \"name\" attribute for the input what will be sent with the form." +msgstr "" +"Scrivere il \"nome\" dell'attributo che deve essere inviato con il modulo." + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:0 +#, python-format +msgid "You can modify the label directly with the website editor." +msgstr "Si può modificare l'etichetta direttamente con l'editor del sito web." + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.dropdown_element_form +msgid "Your Label" +msgstr "La tua etichetta" diff --git a/website_snippet_country_dropdown/i18n/sl.po b/website_snippet_country_dropdown/i18n/sl.po new file mode 100644 index 0000000000..273ce75450 --- /dev/null +++ b/website_snippet_country_dropdown/i18n/sl.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_snippet_country_dropdown +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-09 02:51+0000\n" +"PO-Revision-Date: 2017-06-09 02:51+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page_ir_ui_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +#, fuzzy +msgid "A readonly country dropdown input" +msgstr "Tu testirajte obnašanje spustnega odseka" + +#. module: website_snippet_country_dropdown +#: model:website.menu,name:website_snippet_country_dropdown.country_dropdown_demo_page_link +msgid "Country dropdown demo" +msgstr "Demo spustnega seznama držav" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page_ir_ui_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Other label" +msgstr "Druga oznaka" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page_ir_ui_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Submit (you will see the GET parameters in the URL)" +msgstr "" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page_ir_ui_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Test here the country dropdown snippet behavior" +msgstr "Tu testirajte obnašanje spustnega odseka" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page_ir_ui_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "This is a form" +msgstr "To je obrazec" + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:11 +#, python-format +msgid "" +"Write the \"name\" attribute for the input what will be sent with the form." +msgstr "Zapišite atribut \"naziva\" za vnos vsebine, ki bo poslana z obrazcem." + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:12 +#, python-format +msgid "You can modify the label directly with the website editor." +msgstr "Oznako lahko spremenite neposredno z urejevalnikom spletne strani." + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.dropdown_element_form +msgid "Your Label" +msgstr "Vaša oznaka" diff --git a/website_snippet_country_dropdown/i18n/website_snippet_country_dropdown.pot b/website_snippet_country_dropdown/i18n/website_snippet_country_dropdown.pot new file mode 100644 index 0000000000..021e781229 --- /dev/null +++ b/website_snippet_country_dropdown/i18n/website_snippet_country_dropdown.pot @@ -0,0 +1,69 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_snippet_country_dropdown +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "A readonly country dropdown input" +msgstr "" + +#. module: website_snippet_country_dropdown +#: model:website.menu,name:website_snippet_country_dropdown.country_dropdown_demo_page_link +msgid "Country dropdown demo" +msgstr "" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Other label" +msgstr "" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Submit (you will see the GET parameters in the URL)" +msgstr "" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "Test here the country dropdown snippet behavior" +msgstr "" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view +#: model_terms:website.page,arch_db:website_snippet_country_dropdown.country_dropdown_demo_page +msgid "This is a form" +msgstr "" + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:0 +#, python-format +msgid "" +"Write the \"name\" attribute for the input what will be sent with the form." +msgstr "" + +#. module: website_snippet_country_dropdown +#. openerp-web +#: code:addons/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml:0 +#, python-format +msgid "You can modify the label directly with the website editor." +msgstr "" + +#. module: website_snippet_country_dropdown +#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.dropdown_element_form +msgid "Your Label" +msgstr "" diff --git a/website_snippet_country_dropdown/readme/CONTRIBUTORS.rst b/website_snippet_country_dropdown/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..5d593e9523 --- /dev/null +++ b/website_snippet_country_dropdown/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* `Tecnativa `_: + + * Sergio Teruel + * Jairo Llopis + * Alexandre Díaz + * Carlos Roca + * Ernesto Tejeda diff --git a/website_snippet_country_dropdown/readme/DESCRIPTION.rst b/website_snippet_country_dropdown/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..5f9a55cb63 --- /dev/null +++ b/website_snippet_country_dropdown/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +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. diff --git a/website_snippet_country_dropdown/readme/ROADMAP.rst b/website_snippet_country_dropdown/readme/ROADMAP.rst new file mode 100644 index 0000000000..d69353562f --- /dev/null +++ b/website_snippet_country_dropdown/readme/ROADMAP.rst @@ -0,0 +1,5 @@ +* Add tests. +* 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. diff --git a/website_snippet_country_dropdown/readme/USAGE.rst b/website_snippet_country_dropdown/readme/USAGE.rst new file mode 100644 index 0000000000..bfdcca64be --- /dev/null +++ b/website_snippet_country_dropdown/readme/USAGE.rst @@ -0,0 +1,37 @@ +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. diff --git a/website_snippet_country_dropdown/static/description/icon.png b/website_snippet_country_dropdown/static/description/icon.png new file mode 100644 index 0000000000..b5f9011ea5 Binary files /dev/null and b/website_snippet_country_dropdown/static/description/icon.png differ diff --git a/website_snippet_country_dropdown/static/description/index.html b/website_snippet_country_dropdown/static/description/index.html new file mode 100644 index 0000000000..4191f7cf4b --- /dev/null +++ b/website_snippet_country_dropdown/static/description/index.html @@ -0,0 +1,479 @@ + + + + + + +Website Snippet Country Code Dropdown + + + +
+

Website Snippet Country Code Dropdown

+ + +

Beta License: LGPL-3 OCA/website Translate me on Weblate Try me on Runbot

+

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:

+
    +
  1. no_country_field: Field without code country.
  2. +
  3. country_code_field: Field with only country code (read only)
  4. +
  5. complete_field: Field with the previous two joined (hidden)
  6. +
+

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. +
  3. Extract it from the first 2 letters of the default_value variable.
  4. +
  5. The current user’s country.
  6. +
  7. The current website’s company’s country.
  8. +
  9. The first country in the list.
  10. +
+

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

+ +
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Sergio Teruel
    • +
    • Jairo Llopis
    • +
    • Alexandre Díaz
    • +
    • Carlos Roca
    • +
    • Ernesto Tejeda
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/website project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/website_snippet_country_dropdown/static/src/css/style.scss b/website_snippet_country_dropdown/static/src/css/style.scss new file mode 100644 index 0000000000..4874208f47 --- /dev/null +++ b/website_snippet_country_dropdown/static/src/css/style.scss @@ -0,0 +1,10 @@ +/* Copyright 2015-2016 Jairo Llopis + License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).*/ + +.js_country_dropdown { + .scrollable-menu { + height: auto; + max-height: 200px; + overflow-x: hidden; + } +} diff --git a/website_snippet_country_dropdown/static/src/js/web_tour_country_dropdown.js b/website_snippet_country_dropdown/static/src/js/web_tour_country_dropdown.js new file mode 100644 index 0000000000..81a3fc78b1 --- /dev/null +++ b/website_snippet_country_dropdown/static/src/js/web_tour_country_dropdown.js @@ -0,0 +1,68 @@ +odoo.define("website_snippet_country_dropdown.tour_demo_page", function (require) { + "use strict"; + + const tour = require("web_tour.tour"); + + const country_code_test = "ES"; + const vat_number_test = "B01010101"; + + tour.register( + "website_snippet_country_dropdown_tour_demo_page", + { + url: "/website_snippet_country_dropdown.demo_page", + }, + [ + { + content: "Click Button", + trigger: ".js_enabled .js_btn_country_code", + run: "click", + }, + { + content: "Select Country", + trigger: _.str.sprintf( + ".js_enabled [data-country_code=%s]", + country_code_test + ), + run: "click", + }, + { + content: "Insert text", + trigger: ".js_enabled .js_no_country_field", + extra_trigger: ".js_enabled .js_btn_country_code[data-country_code=ES]", + run: "text " + vat_number_test, + }, + { + trigger: ".btn[type=submit]", + run: "click", + }, + { + trigger: ".js_enabled .js_btn_country_code[data-country_code=US]", + run: function () { + const checks = { + country_code_field: "ES", + complete_field: "ESB01010101", + no_country_field: "B01010101", + disabled_complete_field: "FRA123456789", + disabled_country_code_field: "FR", + disabled_no_country_field: "A123456789", + }; + const query = new URLSearchParams(location.search); + for (const field_name in checks) { + const real = query.get(field_name), + expected = checks[field_name]; + if (real !== expected) { + console.error( + "Tour error: param", + field_name, + "is", + real, + "but should be", + expected + ); + } + } + }, + }, + ] + ); +}); diff --git a/website_snippet_country_dropdown/static/src/js/website_snippet_country_dropdown.js b/website_snippet_country_dropdown/static/src/js/website_snippet_country_dropdown.js new file mode 100644 index 0000000000..a02bc32231 --- /dev/null +++ b/website_snippet_country_dropdown/static/src/js/website_snippet_country_dropdown.js @@ -0,0 +1,75 @@ +/* Copyright 2016 Tecnativa, S.L. + * Copyright 2016 Jairo Llopis + * Copyright 2019 Alexandre Díaz + * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). */ + +odoo.define("website_snippet_country_dropdown.dropdown", function (require) { + "use strict"; + const animation = require("website.content.snippets.animation"); + + const CountryDropdown = animation.Class.extend({ + selector: ".js_country_dropdown", + start: function () { + this._super.apply(this, arguments); + this.$flag_selector = this.$target.find(".js_select_country_code"); + this.$img_code = this.$target.find(".js_img_country_code"); + this.$btn_country_code = this.$target.find(".js_btn_country_code"); + this.$dropdown_list = this.$target.find("#dropdown-countries"); + this.$country_code_field = this.$target.find(".js_country_code_field"); + this.$no_country_field = this.$target.find(".js_no_country_field"); + this.$complete_field_post = this.$target.find(".js_complete_field_post"); + this.$flag_selector.on("click", $.proxy(this.set_value, this)); + this.$no_country_field.on( + "change", + $.proxy(this.on_change_no_country_field, this) + ); + this.$dropdown_list.on( + "scroll", + _.debounce(this.lazy_image_load.bind(this), 35) + ); + this.$target.on("shown.bs.dropdown", this.lazy_image_load.bind(this)); + }, + set_value: function (event) { + this.country_code = event.currentTarget.id; + this.$flag_selector.val(event.currentTarget.id); + this.$img_code.attr("src", event.currentTarget.dataset.country_image_url); + this.$btn_country_code.attr( + "data-country_code", + event.currentTarget.dataset.country_code + ); + this.$country_code_field.val(event.currentTarget.id); + $(this.country_code).children().text(String(event.currentTarget.id)); + this.join_value(event.currentTarget.id, this.$no_country_field.val()); + }, + join_value: function (country_code, value) { + this.$complete_field_post.val(country_code.concat(value)); + }, + on_change_no_country_field: function () { + return this.join_value( + this.$country_code_field.val(), + this.$no_country_field.val() + ); + }, + + is_option_visible: function (elm) { + const ddViewTop = this.$dropdown_list.offset().top; + const ddViewBottom = ddViewTop + this.$dropdown_list.height(); + + const elemTop = elm.offset().top; + const elemBottom = elemTop + elm.height(); + + return elemTop <= ddViewBottom && elemBottom >= ddViewTop; + }, + lazy_image_load: function () { + this.$dropdown_list.children("a").each((index, item) => { + const $elm = $(item); + const $img = $elm.children("img"); + if (!$img.attr("src") && this.is_option_visible($elm)) { + $elm.children("img").attr("src", $elm.data("country_image_url")); + } + }); + }, + }); + + animation.registry.website_snippet_country_dropdown = CountryDropdown; +}); diff --git a/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml b/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml new file mode 100644 index 0000000000..b9889534a3 --- /dev/null +++ b/website_snippet_country_dropdown/static/src/xml/country_dropdown.xml @@ -0,0 +1,17 @@ + + + + +
+
+
+

Write the "name" attribute for the input what will be sent with the form.

+

You can modify the label directly with the website editor.

+
+
+
+
+
diff --git a/website_snippet_country_dropdown/tests/__init__.py b/website_snippet_country_dropdown/tests/__init__.py new file mode 100644 index 0000000000..e17c0cd010 --- /dev/null +++ b/website_snippet_country_dropdown/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2016 Jairo Llopis +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from . import test_snippet_country_dropdown diff --git a/website_snippet_country_dropdown/tests/test_snippet_country_dropdown.py b/website_snippet_country_dropdown/tests/test_snippet_country_dropdown.py new file mode 100644 index 0000000000..2b19c4738f --- /dev/null +++ b/website_snippet_country_dropdown/tests/test_snippet_country_dropdown.py @@ -0,0 +1,10 @@ +# Copyright 2016 Jairo Llopis +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +import odoo.tests + + +class TestUi(odoo.tests.HttpCase): + def test_01_demo_country_dropdown_tour(self): + self.start_tour( + "/", "website_snippet_country_dropdown_tour_demo_page", login="admin" + ) diff --git a/website_snippet_country_dropdown/views/snippets.xml b/website_snippet_country_dropdown/views/snippets.xml new file mode 100644 index 0000000000..171d3cf65d --- /dev/null +++ b/website_snippet_country_dropdown/views/snippets.xml @@ -0,0 +1,114 @@ + + + + + +