diff --git a/website_sale_country_vat_label/README.rst b/website_sale_country_vat_label/README.rst new file mode 100644 index 0000000000..34e18e584d --- /dev/null +++ b/website_sale_country_vat_label/README.rst @@ -0,0 +1,192 @@ +============================== +Website Sale Country VAT Label +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d303099a9c67cdf84db31e7b96350b4257bf819d51b235123d2f9b1b2e8acf28 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-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_country_vat_label + :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_country_vat_label + :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 extends the functionality of the e-commerce platform to +support country-specific tax identifiers and to allow users to see +localized labels for the VAT field during the checkout process. + +By default, Odoo uses a generic "VAT" label in the billing and shipping +address forms, regardless of the customer's country. This module +overrides that behavior by dynamically checking if the selected country +has a custom VAT label defined in its backend configuration (such as +"RUT", "CPF", "NIF", or "EIN") and displays it directly to the customer +on the website. + +This enhancement significantly improves the user experience during +registration and checkout, reducing confusion for international +customers and ensuring higher data accuracy for B2B transactions by +matching official local terminology. + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +Business Need +~~~~~~~~~~~~~ + +In many countries, the term "VAT" (Value Added Tax) is not commonly used +or recognized by local citizens and businesses. For instance, companies +and customers in Chile look for "RUT", in Brazil for "CPF/CNPJ", in +Spain for "NIF/CIF", and in the United States for "EIN". + +When an international or localized e-commerce website forces users to +fill out a field labeled generically as "VAT", it creates friction and +confusion during the checkout process. Users are often unsure whether +they should enter their personal ID, corporate tax number, or if the +field even applies to them. This module resolves this issue by +automatically adapting the form terminology to match local expectations +based on the selected country, thereby reducing cart abandonment and +improving data quality at registration. + +Approach +~~~~~~~~ + +This module extends the standard Odoo website address rendering +controller. It intercepts the dictionary of values sent to the frontend +address form template (``_prepare_address_form_values``) and dynamically +replaces the static 'VAT' string label. It fetches the ``vat_label`` +field configured on the selected country's backend record +(``res.country``). If a specific label is defined for that country, it +is displayed; otherwise, it seamlessly falls back to the standard "VAT" +term. + +Useful Information +~~~~~~~~~~~~~~~~~~ + +- **Dependencies:** This module directly extends ``website_sale`` (the + core Odoo eCommerce module) and relies on the base ``res.country`` + model features. +- **Recommended Setups:** + + - **Multi-website:** Highly recommended for businesses running + multiple localized websites targeting different regions or countries + from a single Odoo database. + - **B2B Portals:** Essential for companies with a heavy B2B focus + where accurate tax identification is mandatory for automated + invoicing. + +- **Complementary Modules:** This module pairs perfectly with OCA + localization modules (such as ``l10n_br_website_sale`` or equivalent + local modules) that enforce specific tax validation rules, ensuring + that the field not only looks right but also validates correctly + according to local laws. + +Usage +===== + +To use this module, you need to: + +1. **Configure the Country VAT Label (Backend):** + + - Go to **Contacts** > **Configuration** > **Countries**. + - Search for and select the country you want to configure (e.g., + *Brazil* or *Chile*). + - In the form view, locate the **VAT Label** field and enter the + local terminology (e.g., *CPF/CNPJ* or *RUT*). + - Click **Save**. + + |Configure Country VAT Label in Backend| + +2. **Check the Website Checkout/Address Form (Frontend):** + + - Go to your **Website** shop. + - Add any product to the cart and proceed to the **Checkout**. + - On the **Billing/Shipping Address** form, select the country you + configured in step 1. + - You will notice that the standard generic **"VAT"** input field + label dynamically changes to match the localized label you defined + (e.g., *RUT* or *CPF/CNPJ*). + + |Dynamic VAT Label during Checkout| + +.. |Configure Country VAT Label in Backend| image:: https://raw.githubusercontent.com/OCA/website/18.0/website_country_vat_label/static/description/country_form.png +.. |Dynamic VAT Label during Checkout| image:: https://raw.githubusercontent.com/OCA/website/18.0/website_country_vat_label/static/description/website_checkout.png + +Changelog +========= + +18.0.1.0.0 (2026-06-04) + +:: + + + - [ADD] Initial version of the module that introduces dynamic, country-specific VAT labels on the website address forms during checkout. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* MTS + +Contributors +------------ + +- Juan Arcos j.arcos@madetosoft.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. + +.. |maintainer-jarcosmts| image:: https://github.com/jarcosmts.png?size=40px + :target: https://github.com/jarcosmts + :alt: jarcosmts + +Current `maintainer `__: + +|maintainer-jarcosmts| + +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_sale_country_vat_label/__init__.py b/website_sale_country_vat_label/__init__.py new file mode 100644 index 0000000000..9613a24bd3 --- /dev/null +++ b/website_sale_country_vat_label/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import controllers diff --git a/website_sale_country_vat_label/__manifest__.py b/website_sale_country_vat_label/__manifest__.py new file mode 100644 index 0000000000..3228c2c21a --- /dev/null +++ b/website_sale_country_vat_label/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2026 MTS - Juan Arcos +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Website Sale Country VAT Label", + "summary": "Use country specific VAT label in website address form", + "version": "18.0.1.0.0", + "development_status": "Beta", + "category": "Website", + "website": "https://github.com/OCA/website", + "author": "MTS, Odoo Community Association (OCA)", + "maintainers": ["jarcosmts"], + "license": "AGPL-3", + "application": False, + "installable": True, + "preloadable": False, + "depends": ["website_sale"], +} diff --git a/website_sale_country_vat_label/controllers/__init__.py b/website_sale_country_vat_label/controllers/__init__.py new file mode 100644 index 0000000000..f43232f012 --- /dev/null +++ b/website_sale_country_vat_label/controllers/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import main diff --git a/website_sale_country_vat_label/controllers/main.py b/website_sale_country_vat_label/controllers/main.py new file mode 100644 index 0000000000..c08da28272 --- /dev/null +++ b/website_sale_country_vat_label/controllers/main.py @@ -0,0 +1,23 @@ +# Copyright 2026 MTS - Juan Arcos +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.http import request + +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteSaleVatLabel(WebsiteSale): + def _prepare_address_form_values(self, *args, **kwargs): + """Extend standard address values to support country-specific VAT labels. + + This method overrides the generic 'VAT' label by checking if the + currently selected country has a custom label configured (e.g., RUT, + CPF). If found, it replaces the default label to improve localization. + """ + res = super()._prepare_address_form_values(*args, **kwargs) + country_sudo = res.get("country") + + if country_sudo: + res["vat_label"] = country_sudo.vat_label or request.env._("VAT") + + return res diff --git a/website_sale_country_vat_label/pyproject.toml b/website_sale_country_vat_label/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/website_sale_country_vat_label/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/website_sale_country_vat_label/readme/CONTEXT.md b/website_sale_country_vat_label/readme/CONTEXT.md new file mode 100644 index 0000000000..f27a5c4d57 --- /dev/null +++ b/website_sale_country_vat_label/readme/CONTEXT.md @@ -0,0 +1,17 @@ +### Business Need + +In many countries, the term "VAT" (Value Added Tax) is not commonly used or recognized by local citizens and businesses. For instance, companies and customers in Chile look for "RUT", in Brazil for "CPF/CNPJ", in Spain for "NIF/CIF", and in the United States for "EIN". + +When an international or localized e-commerce website forces users to fill out a field labeled generically as "VAT", it creates friction and confusion during the checkout process. Users are often unsure whether they should enter their personal ID, corporate tax number, or if the field even applies to them. This module resolves this issue by automatically adapting the form terminology to match local expectations based on the selected country, thereby reducing cart abandonment and improving data quality at registration. + +### Approach + +This module extends the standard Odoo website address rendering controller. It intercepts the dictionary of values sent to the frontend address form template (`_prepare_address_form_values`) and dynamically replaces the static 'VAT' string label. It fetches the `vat_label` field configured on the selected country's backend record (`res.country`). If a specific label is defined for that country, it is displayed; otherwise, it seamlessly falls back to the standard "VAT" term. + +### Useful Information + +* **Dependencies:** This module directly extends `website_sale` (the core Odoo eCommerce module) and relies on the base `res.country` model features. +* **Recommended Setups:** + * **Multi-website:** Highly recommended for businesses running multiple localized websites targeting different regions or countries from a single Odoo database. + * **B2B Portals:** Essential for companies with a heavy B2B focus where accurate tax identification is mandatory for automated invoicing. +* **Complementary Modules:** This module pairs perfectly with OCA localization modules (such as `l10n_br_website_sale` or equivalent local modules) that enforce specific tax validation rules, ensuring that the field not only looks right but also validates correctly according to local laws. \ No newline at end of file diff --git a/website_sale_country_vat_label/readme/CONTRIBUTORS.md b/website_sale_country_vat_label/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..5e60bc926a --- /dev/null +++ b/website_sale_country_vat_label/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Juan Arcos diff --git a/website_sale_country_vat_label/readme/DESCRIPTION.md b/website_sale_country_vat_label/readme/DESCRIPTION.md new file mode 100644 index 0000000000..befcb0e62b --- /dev/null +++ b/website_sale_country_vat_label/readme/DESCRIPTION.md @@ -0,0 +1,5 @@ +This module extends the functionality of the e-commerce platform to support country-specific tax identifiers and to allow users to see localized labels for the VAT field during the checkout process. + +By default, Odoo uses a generic "VAT" label in the billing and shipping address forms, regardless of the customer's country. This module overrides that behavior by dynamically checking if the selected country has a custom VAT label defined in its backend configuration (such as "RUT", "CPF", "NIF", or "EIN") and displays it directly to the customer on the website. + +This enhancement significantly improves the user experience during registration and checkout, reducing confusion for international customers and ensuring higher data accuracy for B2B transactions by matching official local terminology. \ No newline at end of file diff --git a/website_sale_country_vat_label/readme/HISTORY.md b/website_sale_country_vat_label/readme/HISTORY.md new file mode 100644 index 0000000000..8cc951b07c --- /dev/null +++ b/website_sale_country_vat_label/readme/HISTORY.md @@ -0,0 +1,4 @@ +18.0.1.0.0 (2026-06-04) +~~~~~~~~~~~~~~~~~~~~~~~ + +- [ADD] Initial version of the module that introduces dynamic, country-specific VAT labels on the website address forms during checkout. \ No newline at end of file diff --git a/website_sale_country_vat_label/readme/USAGE.md b/website_sale_country_vat_label/readme/USAGE.md new file mode 100644 index 0000000000..8784f79de6 --- /dev/null +++ b/website_sale_country_vat_label/readme/USAGE.md @@ -0,0 +1,17 @@ +To use this module, you need to: + +1. **Configure the Country VAT Label (Backend):** + * Go to **Contacts** > **Configuration** > **Countries**. + * Search for and select the country you want to configure (e.g., *Brazil* or *Chile*). + * In the form view, locate the **VAT Label** field and enter the local terminology (e.g., *CPF/CNPJ* or *RUT*). + * Click **Save**. + + ![Configure Country VAT Label in Backend](static/description/country_form.png) + +2. **Check the Website Checkout/Address Form (Frontend):** + * Go to your **Website** shop. + * Add any product to the cart and proceed to the **Checkout**. + * On the **Billing/Shipping Address** form, select the country you configured in step 1. + * You will notice that the standard generic **"VAT"** input field label dynamically changes to match the localized label you defined (e.g., *RUT* or *CPF/CNPJ*). + + ![Dynamic VAT Label during Checkout](static/description/website_checkout.png) \ No newline at end of file diff --git a/website_sale_country_vat_label/readme/newsfragments/.gitkeep b/website_sale_country_vat_label/readme/newsfragments/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/website_sale_country_vat_label/static/description/country_form.png b/website_sale_country_vat_label/static/description/country_form.png new file mode 100644 index 0000000000..d64ec4e793 Binary files /dev/null and b/website_sale_country_vat_label/static/description/country_form.png differ diff --git a/website_sale_country_vat_label/static/description/icon.png b/website_sale_country_vat_label/static/description/icon.png new file mode 100644 index 0000000000..1dcc49c24f Binary files /dev/null and b/website_sale_country_vat_label/static/description/icon.png differ diff --git a/website_sale_country_vat_label/static/description/icon.svg b/website_sale_country_vat_label/static/description/icon.svg new file mode 100644 index 0000000000..ed6aaa04e4 --- /dev/null +++ b/website_sale_country_vat_label/static/description/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/website_sale_country_vat_label/static/description/index.html b/website_sale_country_vat_label/static/description/index.html new file mode 100644 index 0000000000..f92d18ab8d --- /dev/null +++ b/website_sale_country_vat_label/static/description/index.html @@ -0,0 +1,124 @@ +
+
+
+

Module name

+

This module was written to extend the functionality of ... to support ... and allow you to ...

+
+
+
+ +
+
+
+

Installation

+
+
+

To install this module, you need to: +

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Configuration

+
+
+

To configure this module, you need to: +

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Usage

+
+
+

To use this module, you need to: +

    +
  • ...
  • +
+

+

For further information, please visit: +

+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Known issues / Roadmap

+
+
+

+

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Credits

+
+
+

Contributors

+ +
+
+

Maintainer

+

+ This module is maintained by the OCA.
+ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
+ To contribute to this module, please visit http://odoo-community.org.
+ +

+
+
+
diff --git a/website_sale_country_vat_label/static/description/website_checkout.png b/website_sale_country_vat_label/static/description/website_checkout.png new file mode 100644 index 0000000000..4c3082721f Binary files /dev/null and b/website_sale_country_vat_label/static/description/website_checkout.png differ diff --git a/website_sale_country_vat_label/tests/__init__.py b/website_sale_country_vat_label/tests/__init__.py new file mode 100644 index 0000000000..c40f5b876f --- /dev/null +++ b/website_sale_country_vat_label/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_country_vat_label diff --git a/website_sale_country_vat_label/tests/test_country_vat_label.py b/website_sale_country_vat_label/tests/test_country_vat_label.py new file mode 100644 index 0000000000..df0a24ddf3 --- /dev/null +++ b/website_sale_country_vat_label/tests/test_country_vat_label.py @@ -0,0 +1,35 @@ +# Copyright 2026 MTS - Juan Arcos +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import HttpCase, tagged + + +@tagged("post_install", "-at_install") +class TestWebsiteSaleVatLabel(HttpCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.country_custom = cls.env["res.country"].search([], limit=1) + cls.country_custom.vat_label = "RUT" + + cls.country_default = cls.env["res.country"].create( + { + "name": "Test Country No Label", + "code": "XX", + "vat_label": False, + } + ) + + def test_prepare_address_form_values_via_controller(self): + """Test country-specific VAT labels through the website sale controller.""" + self.authenticate("admin", "admin") + + response_custom = self.url_open( + f"/shop/address?country_id={self.country_custom.id}" + ) + self.assertEqual(response_custom.status_code, 200) + + response_default = self.url_open( + f"/shop/address?country_id={self.country_default.id}" + ) + self.assertEqual(response_default.status_code, 200)