Initial commit: OCA Website packages (16 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:06 +02:00
commit 0578ef7638
660 changed files with 37334 additions and 0 deletions

View file

@ -0,0 +1,46 @@
# Website Snippet Country Code Dropdown
Odoo addon: website_snippet_country_dropdown
## Installation
```bash
pip install odoo-bringout-oca-website-website_snippet_country_dropdown
```
## Dependencies
This addon depends on:
- website
## Manifest Information
- **Name**: Website Snippet Country Code Dropdown
- **Version**: 16.0.1.0.0
- **Category**: Website
- **License**: LGPL-3
- **Installable**: True
## Source
Based on [OCA/website](https://github.com/OCA/website) branch 16.0, addon `website_snippet_country_dropdown`.
## License
This package maintains the original LGPL-3 license from the upstream Odoo project.
## Documentation
- Overview: doc/OVERVIEW.md
- Architecture: doc/ARCHITECTURE.md
- Models: doc/MODELS.md
- Controllers: doc/CONTROLLERS.md
- Wizards: doc/WIZARDS.md
- Reports: doc/REPORTS.md
- Security: doc/SECURITY.md
- Install: doc/INSTALL.md
- Usage: doc/USAGE.md
- Configuration: doc/CONFIGURATION.md
- Dependencies: doc/DEPENDENCIES.md
- Troubleshooting: doc/TROUBLESHOOTING.md
- FAQ: doc/FAQ.md

View file

@ -0,0 +1,32 @@
# Architecture
```mermaid
flowchart TD
U[Users] -->|HTTP| V[Views and QWeb Templates]
V --> C[Controllers]
V --> W[Wizards Transient Models]
C --> M[Models and ORM]
W --> M
M --> R[Reports]
DX[Data XML] --> M
S[Security ACLs and Groups] -. enforces .-> M
subgraph Website_snippet_country_dropdown Module - website_snippet_country_dropdown
direction LR
M:::layer
W:::layer
C:::layer
V:::layer
R:::layer
S:::layer
DX:::layer
end
classDef layer fill:#eef8ff,stroke:#6ea8fe,stroke-width:1px
```
Notes
- Views include tree/form/kanban templates and report templates.
- Controllers provide website/portal routes when present.
- Wizards are UI flows implemented with `models.TransientModel`.
- Data XML loads data/demo records; Security defines groups and access.

View file

@ -0,0 +1,3 @@
# Configuration
Refer to Odoo settings for website_snippet_country_dropdown. Configure related models, access rights, and options as needed.

View file

@ -0,0 +1,3 @@
# Controllers
This module does not define custom HTTP controllers.

View file

@ -0,0 +1,5 @@
# Dependencies
This addon depends on:
- [website](../../odoo-bringout-oca-ocb-website)

View file

@ -0,0 +1,4 @@
# FAQ
- Q: Which Odoo version? A: 16.0 (OCA/OCB packaged).
- Q: How to enable? A: Start server with --addon website_snippet_country_dropdown or install in UI.

View file

@ -0,0 +1,7 @@
# Install
```bash
pip install odoo-bringout-oca-website-website_snippet_country_dropdown"
# or
uv pip install odoo-bringout-oca-website-website_snippet_country_dropdown"
```

View file

@ -0,0 +1,11 @@
# Models
Detected core models and extensions in website_snippet_country_dropdown.
```mermaid
classDiagram
```
Notes
- Classes show model technical names; fields omitted for brevity.
- Items listed under _inherit are extensions of existing models.

View file

@ -0,0 +1,6 @@
# Overview
Packaged Odoo addon: website_snippet_country_dropdown. Provides features documented in upstream Odoo 16 under this addon.
- Source: OCA/OCB 16.0, addon website_snippet_country_dropdown
- License: LGPL-3

View file

@ -0,0 +1,3 @@
# Reports
This module does not define custom reports.

View file

@ -0,0 +1,8 @@
# Security
This module does not define custom security rules or access controls beyond Odoo defaults.
Default Odoo security applies:
- Base user access through standard groups
- Model access inherited from dependencies
- No custom row-level security rules

View file

@ -0,0 +1,5 @@
# Troubleshooting
- Ensure Python and Odoo environment matches repo guidance.
- Check database connectivity and logs if startup fails.
- Validate that dependent addons listed in DEPENDENCIES.md are installed.

View file

@ -0,0 +1,7 @@
# Usage
Start Odoo including this addon (from repo root):
```bash
python3 scripts/nix_odoo_web_server.py --db-name mydb --addon website_snippet_country_dropdown
```

View file

@ -0,0 +1,3 @@
# Wizards
This module does not include UI wizards.

View file

@ -0,0 +1,42 @@
[project]
name = "odoo-bringout-oca-website-website_snippet_country_dropdown"
version = "16.0.0"
description = "Website Snippet Country Code Dropdown - Allow to select country in a dropdown"
authors = [
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
]
dependencies = [
"odoo-bringout-oca-ocb-website>=16.0.0",
"requests>=2.25.1"
]
readme = "README.md"
requires-python = ">= 3.11"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Office/Business",
]
[project.urls]
homepage = "https://github.com/bringout/0"
repository = "https://github.com/bringout/0"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.metadata]
allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["website_snippet_country_dropdown"]
[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.4.1",
]

View file

@ -0,0 +1,135 @@
=====================================
Website Snippet Country Code Dropdown
=====================================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b399fa24604cc6a35b43ac04315fd792ae401e6bc0ecf437e6cdb32e01e7fb51
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/16.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-16-0/website-16-0-website_snippet_country_dropdown
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/website&target_branch=16.0
:alt: Try me on Runboat
|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.
<https://github.com/OCA/website/pull/230#issuecomment-236681777>`_.
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 <https://github.com/OCA/website/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/website/issues/new?body=module:%20website_snippet_country_dropdown%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* Tecnativa
Contributors
~~~~~~~~~~~~
* `Tecnativa <https://www.tecnativa.com>`_:
* 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 <https://github.com/OCA/website/tree/16.0/website_snippet_country_dropdown>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View file

@ -0,0 +1,2 @@
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

View file

@ -0,0 +1,32 @@
# Copyright 2016 Sergio Teruel <sergio.teruel@tecnativa.com>
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# 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"
],
},
}

View file

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
Copyright 2019 Alexandre Díaz <alexandre.diaz@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="country_dropdown_demo_view" name="Country dropdown snippet test">
<t t-call="website.layout">
<div id="wrap" class="oe_structure oe_empty">
<section>
<div class="container readable mt32 mb32">
<div class="row">
<div class="col-md-12">
<h1 class="text-center">This is a form</h1>
<h3 class="text-muted text-center">
Test here the country dropdown snippet behavior
</h3>
<form action="" class="form-horizontal">
<div
class="js_enabled"
t-call="website_snippet_country_dropdown.dropdown_element_form"
>
<t
t-set="label_class"
t-value="'col-sm-5 col-form-label'"
/>
<t
t-set="input_container_class"
t-value="'col-sm-7'"
/>
<t t-set="label_country_dropdown">
Other label
</t>
</div>
<div
class="js_disabled"
t-call="website_snippet_country_dropdown.dropdown_element_form"
>
<t
t-set="label_class"
t-value="'col-sm-5 col-form-label'"
/>
<t
t-set="input_container_class"
t-value="'col-sm-7'"
/>
<t
t-set="complete_field"
t-value="'disabled_complete_field'"
/>
<t
t-set="country_code_field"
t-value="'disabled_country_code_field'"
/>
<t
t-set="no_country_field"
t-value="'disabled_no_country_field'"
/>
<t t-set="readonly" t-value="True" />
<t
t-set="default_value"
t-value="'FRA123456789'"
/>
<t t-set="label_country_dropdown">
A readonly country dropdown input
</t>
</div>
<div class="col-12 d-flex justify-content-center">
<button type="submit" class="btn btn-default">
Submit (you will see the GET parameters in the URL)
</button>
</div>
</form>
</div>
</div>
</div>
</section>
</div>
</t>
</template>
<record id="country_dropdown_demo_page" model="website.page">
<field name="website_published">True</field>
<field name="url">/website_snippet_country_dropdown.demo_page</field>
<field name="view_id" ref="country_dropdown_demo_view" />
</record>
<record id="country_dropdown_demo_page_link" model="website.menu">
<field name="name">Country dropdown demo</field>
<field name="url">/website_snippet_country_dropdown.demo_page</field>
<field name="parent_id" ref="website.main_menu" />
<field name="sequence" type="int">50</field>
<field name="page_id" ref="country_dropdown_demo_page" />
</record>
</odoo>

View file

@ -0,0 +1,64 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_snippet_country_dropdown
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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
msgid "A readonly country dropdown input"
msgstr "Unos padajućeg popisa zemlje samo za čitanje"
#. module: website_snippet_country_dropdown
#: model:website.menu,name:website_snippet_country_dropdown.country_dropdown_demo_page_link
msgid "Country dropdown demo"
msgstr "Demo padajućeg popisa zemlje"
#. module: website_snippet_country_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view
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_view
msgid "Submit (you will see the GET parameters in the URL)"
msgstr "Pošalji (vidjet ćete GET parametre u URL-u)"
#. module: website_snippet_country_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view
msgid "Test here the country dropdown snippet behavior"
msgstr "Testirajte ovdje ponašanje padajućeg popisa zemlje"
#. module: website_snippet_country_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view
msgid "This is a form"
msgstr "Ovo je form"
#. module: website_snippet_country_dropdown
#. odoo-javascript
#: 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
#. odoo-javascript
#: 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 "Možete modificirati oznaku direktno s uređivačem web stranice."
#. 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"

View file

@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_snippet_country_dropdown
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <claudia.gargallo@qubiq.es>\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
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
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
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
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
msgid "This is a form"
msgstr "Esto es un formulario"
#. module: website_snippet_country_dropdown
#. odoo-javascript
#: 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
#. odoo-javascript
#: 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"

View file

@ -0,0 +1,74 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_snippet_country_dropdown
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
# Quentin THEURET <odoo@kerpeo.com>, 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 <odoo@kerpeo.com>, 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
#, 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
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
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
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
msgid "This is a form"
msgstr "C'est un formulaire"
#. module: website_snippet_country_dropdown
#. odoo-javascript
#: 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
#. odoo-javascript
#: 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é"

View file

@ -0,0 +1,68 @@
# 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 <stefano.consolaro@mymage.it>\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
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
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
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
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
msgid "This is a form"
msgstr "Questo è un modulo"
#. module: website_snippet_country_dropdown
#. odoo-javascript
#: 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
#. odoo-javascript
#: 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"

View file

@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_snippet_country_dropdown
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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_view
#, 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_view
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_view
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
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_view
msgid "This is a form"
msgstr "To je obrazec"
#. module: website_snippet_country_dropdown
#. odoo-javascript
#: 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 "Zapišite atribut \"naziva\" za vnos vsebine, ki bo poslana z obrazcem."
#. module: website_snippet_country_dropdown
#. odoo-javascript
#: 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 "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"

View file

@ -0,0 +1,64 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_snippet_country_dropdown
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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
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
msgid "Other label"
msgstr ""
#. module: website_snippet_country_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_dropdown.country_dropdown_demo_view
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
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
msgid "This is a form"
msgstr ""
#. module: website_snippet_country_dropdown
#. odoo-javascript
#: 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
#. odoo-javascript
#: 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 ""

View file

@ -0,0 +1,7 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* Sergio Teruel
* Jairo Llopis
* Alexandre Díaz
* Carlos Roca
* Ernesto Tejeda

View file

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

View file

@ -0,0 +1,5 @@
* Add tests.
* Snippet drag and drop `seems to be blocked by Odoo for some unknown reason.
<https://github.com/OCA/website/pull/230#issuecomment-236681777>`_.
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.

View file

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

View file

@ -0,0 +1,480 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Website Snippet Country Code Dropdown</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="website-snippet-country-code-dropdown">
<h1 class="title">Website Snippet Country Code Dropdown</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b399fa24604cc6a35b43ac04315fd792ae401e6bc0ecf437e6cdb32e01e7fb51
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/website/tree/16.0/website_snippet_country_dropdown"><img alt="OCA/website" src="https://img.shields.io/badge/github-OCA%2Fwebsite-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/website-16-0/website-16-0-website_snippet_country_dropdown"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/website&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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.</p>
<p>This can be inserted into form elements.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a><ul>
<li><a class="reference internal" href="#development" id="toc-entry-2">Development</a></li>
</ul>
</li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>To extend this template you need to inherit <tt class="docutils literal">country_dropdown</tt> template and
add your personal code.</p>
<p>The template have three input text:</p>
<ol class="arabic simple">
<li><tt class="docutils literal">no_country_field</tt>: Field without code country.</li>
<li><tt class="docutils literal">country_code_field</tt>: Field with only country code (read only)</li>
<li><tt class="docutils literal">complete_field</tt>: Field with the previous two joined (hidden)</li>
</ol>
<p>The name of the complete field is customizable when user insert the snippet
into a form element with the website editor.</p>
<div class="section" id="development">
<h2><a class="toc-backref" href="#toc-entry-2">Development</a></h2>
<p>You can call the reusable Qweb template called
<tt class="docutils literal">website_snippet_country_dropdown.country_dropdown</tt> in your views to add a
sensible country-combined field, ideal for <em>VATs</em>.</p>
<p>The default country will be the first match among:</p>
<ol class="arabic simple">
<li>Extract it from the <tt class="docutils literal">default_country</tt> variable.</li>
<li>Extract it from the first 2 letters of the <tt class="docutils literal">default_value</tt> variable.</li>
<li>The current users country.</li>
<li>The current websites companys country.</li>
<li>The first country in the list.</li>
</ol>
<p>All variables you can use to modify its behavior:</p>
<ul class="simple">
<li><tt class="docutils literal">complete_field</tt> to give it a name. Usually it will match the field name.</li>
<li><tt class="docutils literal">default_value</tt> for the <tt class="docutils literal">complete_field</tt>.</li>
<li><tt class="docutils literal">countries</tt> as a <tt class="docutils literal">res.country</tt> ORM recordset.</li>
<li><tt class="docutils literal">default_country</tt> as a <tt class="docutils literal">res.country</tt> record.</li>
<li><tt class="docutils literal">no_country_placeholder</tt>.</li>
</ul>
<p>You can view an example in <tt class="docutils literal">website_sale_checkout_country_vat</tt> in
OCA/e-commerce.</p>
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Add tests.</li>
<li>Snippet drag and drop <a class="reference external" href="https://github.com/OCA/website/pull/230#issuecomment-236681777">seems to be blocked by Odoo for some unknown reason.</a>.
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.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/website/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/website/issues/new?body=module:%20website_snippet_country_dropdown%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Sergio Teruel</li>
<li>Jairo Llopis</li>
<li>Alexandre Díaz</li>
<li>Carlos Roca</li>
<li>Ernesto Tejeda</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/website/tree/16.0/website_snippet_country_dropdown">OCA/website</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,10 @@
/* Copyright 2015-2016 Jairo Llopis <jairo.llopis@tecnativa.com>
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;
}
}

View file

@ -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
);
}
}
},
},
]
);
});

View file

@ -0,0 +1,75 @@
/* Copyright 2016 Tecnativa, S.L.
* Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
* Copyright 2019 Alexandre Díaz <alexandre.diaz@tecnativa.com>
* 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;
});

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- © 2016 Sergio Teruel <sergio.teruel@tecnativa.com>
© 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<templates>
<t t-name="website_snippet_country_dropdown.helper">
<div class="row mt8">
<div class="col-sm-9 col-sm-offset-3">
<div class="alert alert-info">
<p
>Write the "name" attribute for the input what will be sent with the form.</p>
<p>You can modify the label directly with the website editor.</p>
</div>
</div>
</div>
</t>
</templates>

View file

@ -0,0 +1,4 @@
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import test_snippet_country_dropdown

View file

@ -0,0 +1,10 @@
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# 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"
)

View file

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Sergio Teruel <sergio.teruel@tecnativa.com>
Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="dropdown_element_form" name="Country Dropdown Input">
<t
t-set="label_class"
t-value="label_class or 'col-md-2 col-sm-3 col-form-label'"
/>
<t
t-set="input_container_class"
t-value="input_container_class or 'col-md-7 col-sm-8'"
/>
<div
t-attf-class="form-group #{extra_class or ''} o_country_dropdown row"
t-ignore="true"
>
<label t-att-class="label_class" t-att-for="complete_field">
<span t-if="label_country_dropdown" t-esc="label_country_dropdown" />
<span t-if="not label_country_dropdown">Your Label</span>
</label>
<div t-att-class="input_container_class">
<t t-call="website_snippet_country_dropdown.country_dropdown">
<t t-out="0" />
</t>
</div>
</div>
</template>
<template id="country_dropdown" name="Country Dropdown">
<t t-set="default_value" t-value="default_value or ''" />
<t
t-set="no_country_field_extra_classes"
t-value="no_country_field_extra_classes 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 request.env.user.country_id or website.company_id.country_id or countries[:1]"
/>
<t t-set="readonly" t-value="readonly or False" />
<t t-set="complete_field" t-value="complete_field or 'complete_field'" />
<t
t-set="country_code_field"
t-value="country_code_field or 'country_code_field'"
/>
<t t-set="no_country_field" t-value="no_country_field or 'no_country_field'" />
<div class="input-group js_country_dropdown" t-ignore="true">
<div class="input-group-prepend flag-button">
<button
type="button"
id="btn_vat_code"
t-att-disabled="readonly"
class="btn btn-outline-secondary dropdown-toggle js_btn_country_code form-control"
data-bs-toggle="dropdown"
t-att-data-country_code="default_country.code"
>
<img
id="img_code_vat"
class="js_img_country_code"
t-att-src="default_country.image_url"
width="30"
height="20"
/>
</button>
<div class="dropdown-menu scrollable-menu" id="dropdown-countries">
<t t-foreach="countries" t-as="country">
<a
href="#"
t-att-id="country.code"
t-att-data-country_id="country.id"
t-att-data-country_code="country.code"
t-att-data-country_image_url="country.image_url"
class="dropdown-item js_select_country_code"
>
<img
t-att-data-country-id="country.id"
width="30"
height="20"
/>
<span t-esc="country.name" />
</a>
</t>
</div>
</div>
<input
id="country_code_field"
type="text"
size="2"
tabindex="-1"
class="input-group-text js_country_code_field"
t-att-name="country_code_field"
t-att-value="default_country.code"
readonly="1"
/>
<input
id="complete_field"
type="hidden"
class="js_complete_field_post"
t-att-name="complete_field"
t-att-value="default_value"
/>
<input
id="no_country_field"
type="text"
t-attf-class="form-control js_no_country_field #{no_country_field_extra_classes}"
t-att-name="no_country_field"
t-att-readonly="readonly"
t-att-placeholder="no_country_placeholder"
t-att-value="default_value[2:] if default_country.code == default_value[:2].upper() else default_value"
/>
</div>
</template>
</odoo>