Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions website_snippet_country_phone_code_dropdown/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
===========================================
Website Snippet Country Phone Code Dropdown
===========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:af3a26574c6f70e54f7e2131a4c5c429db1d6619b81eb4724517a212f0e0a7af
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/18.0/website_snippet_country_phone_code_dropdown
:alt: OCA/website
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/website-18-0/website-18-0-website_snippet_country_phone_code_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=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module enhances the features of the
website_snippet_country_dropdown module, and its implementation and
functionality are very similar. It offers a snippet with a dropdown for
selecting a country as well as an input text field that auto-populates
with the corresponding phone code. This module is intended to serve as a
base for other modules to inherit and integrate into HTML forms.

**Table of contents**

.. contents::
:local:

Usage
=====

To extend this template, you should inherit the country_dropdown
template and add your custom code. This template includes three input
text fields, which are the following:

1. ``no_country_field``: Field without code country.
2. ``country_phone_code_field``: Field with only country code (read
only)
3. ``complete_field``: Field with the previous two joined (hidden)

The name of the complete field is customizable when user insert the
snippet into a form element with the website editor.

Development
-----------

In order to use this element, you can call the reusable Qweb template
website_snippet_country_phone_code_dropdown.country_dropdown in your
views or forms to add a sensible country-combined field, which could be
a useful element for the registration of international phone numbers.

**Default Country Selection**

The default country will be determined by the first match among:

1. Extracted from the default_country variable.
2. Extracted from the default_value_prefix variable, searching by phone
code.
3. The current user's country.
4. The current website's company's country.
5. The first country in the list.

**Variables**

All variables you can use to modify its behavior:

1. ``complete_field``: To give the form information a name. Habitually
it will match the field name.
2. ``default_value_prefix``: The phone prefix to be used in the
complete_field.
3. ``default_value_number``: The phone number to be used in the
complete_field.
4. ``countries``: A recordset of res.country containing all the
available countries.
5. ``default_country``: A res.country record representing the default
country.
6. ``no_country_placeholder``: A placeholder text for the phone number
input field.

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_phone_code_dropdown%0Aversion:%2018.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
-------

* ForgeFlow

Contributors
------------

- Laura Cazorla <laura.cazorla@forgeflow.com>

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/18.0/website_snippet_country_phone_code_dropdown>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions website_snippet_country_phone_code_dropdown/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
27 changes: 27 additions & 0 deletions website_snippet_country_phone_code_dropdown/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Website Snippet Country Phone Code Dropdown",
"summary": "Allow to select country in a dropdown, and fill with phone code",
"version": "18.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/website",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": ["website_snippet_country_dropdown"],
"data": ["views/snippets.xml"],
"demo": ["demo/pages.xml"],
"assets": {
"web.assets_tests": [
"/website_snippet_country_phone_code_dropdown/static/src/js/"
"web_tour_country_phone_code_dropdown.esm.js"
],
"web.assets_frontend": [
"/website_snippet_country_phone_code_dropdown/static/src/css/style.scss",
"/website_snippet_country_phone_code_dropdown/static/src/js/"
"website_snippet_country_phone_code_dropdown.esm.js",
],
},
}
100 changes: 100 additions & 0 deletions website_snippet_country_phone_code_dropdown/demo/pages.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template
id="country_phone_code_dropdown_demo_view"
name="Country phone code dropdown snippet test"
>
<t t-call="website.layout">
<div id="wrap">
<section>
<div class="container readable mt32 mb32">
<div class="row">
<div class="col-md-12">
<h1 class="text-center">This is a form</h1>
<h4 class="text-muted text-center mt-3">
Test the country phone code dropdown snippet
</h4>
<form action="" class="form-horizontal mt-4">
<div
class="js_enabled"
t-call="website_snippet_country_phone_code_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"
>Example label</t>
</div>
<div
class="js_disabled mt-2"
t-call="website_snippet_country_phone_code_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_phone_code_field"
t-value="'disabled_country_phone_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_prefix"
t-value="'33'"
/>
<t
t-set="default_value_number"
t-value="'6 00 11 22 33'"
/>
<t
t-set="label_country_dropdown"
>Example label (readonly)</t>
</div>
<div
class="col-12 d-flex justify-content-center mt-2"
>
<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_phone_code_demo_page" model="website.page">
<field name="website_published">True</field>
<field name="url">/website_snippet_country_phone_code_dropdown.demo_page</field>
<field name="view_id" ref="country_phone_code_dropdown_demo_view" />
</record>
<record id="country_dropdown_phone_code_demo_page_link" model="website.menu">
<field name="name">Country Phone Code Dropdown Demo</field>
<field name="url">/website_snippet_country_phone_code_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_phone_code_demo_page" />
</record>
</odoo>
52 changes: 52 additions & 0 deletions website_snippet_country_phone_code_dropdown/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_snippet_country_phone_code_dropdown
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-08-25 10:25+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 5.10.4\n"

#. module: website_snippet_country_phone_code_dropdown
#: model:website.menu,name:website_snippet_country_phone_code_dropdown.country_dropdown_phone_code_demo_page_link
msgid "Country Phone Code Dropdown Demo"
msgstr "Demo trascinamento codice telefono nazione"

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_dropdown_demo_view
msgid "Example label"
msgstr "Etichetta esempio"

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_dropdown_demo_view
msgid "Example label (readonly)"
msgstr "Etichetta esempio (solo lettura)"

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_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_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_dropdown_demo_view
msgid "Test the country phone code dropdown snippet"
msgstr "Testa il codice esempio di trascinamento codice telefono nazione"

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_dropdown_demo_view
msgid "This is a form"
msgstr "Questo è un modulo"

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.dropdown_element_form
msgid "Your Label"
msgstr "La tua etichetta"
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_snippet_country_phone_code_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_phone_code_dropdown
#: model:website.menu,name:website_snippet_country_phone_code_dropdown.country_dropdown_phone_code_demo_page_link
msgid "Country Phone Code Dropdown Demo"
msgstr ""

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_dropdown_demo_view
msgid "Example label"
msgstr ""

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_dropdown_demo_view
msgid "Example label (readonly)"
msgstr ""

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_dropdown_demo_view
msgid "Submit (you will see the GET parameters in the URL)"
msgstr ""

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_dropdown_demo_view
msgid "Test the country phone code dropdown snippet"
msgstr ""

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.country_phone_code_dropdown_demo_view
msgid "This is a form"
msgstr ""

#. module: website_snippet_country_phone_code_dropdown
#: model_terms:ir.ui.view,arch_db:website_snippet_country_phone_code_dropdown.dropdown_element_form
msgid "Your Label"
msgstr ""
3 changes: 3 additions & 0 deletions website_snippet_country_phone_code_dropdown/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Laura Cazorla \<<laura.cazorla@forgeflow.com>\>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module enhances the features of the
website_snippet_country_dropdown module, and its implementation and
functionality are very similar. It offers a snippet with a dropdown for
selecting a country as well as an input text field that auto-populates
with the corresponding phone code. This module is intended to serve as a
base for other modules to inherit and integrate into HTML forms.
Loading
Loading