diff --git a/website_sale_vat_required/README.rst b/website_sale_vat_required/README.rst new file mode 100644 index 0000000000..affc5a4a6f --- /dev/null +++ b/website_sale_vat_required/README.rst @@ -0,0 +1,100 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +======================= +e-commerce required VAT +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0ad8d5cfff4cc37f994c28fc6594b8f594e3b6769a263e5451eb847240221d0f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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%2Fe--commerce-lightgray.png?logo=github + :target: https://github.com/OCA/e-commerce/tree/19.0/website_sale_vat_required + :alt: OCA/e-commerce +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/e-commerce-19-0/e-commerce-19-0-website_sale_vat_required + :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/e-commerce&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends checkout e-commerce form in order to force user to +fill 'VAT number' field. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +1. Buy something from your e-commerce +2. Go to checkout page. +3. Try to checkout without specifying a VAT, or using a wrong one. +4. You will get an error. + +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 +------- + +* Agile Business Group +* Tecnativa + +Contributors +------------ + +- Lorenzo Battistini + +- `Tecnativa `__: + + - Jairo Llopis + - Ernesto Tejeda + - Carlos Lopez + +- Abraham Anes + +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/e-commerce `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_sale_vat_required/__init__.py b/website_sale_vat_required/__init__.py new file mode 100644 index 0000000000..101874fb38 --- /dev/null +++ b/website_sale_vat_required/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2015 Agile Business Group sagl () +# Copyright 2017 Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import controllers diff --git a/website_sale_vat_required/__manifest__.py b/website_sale_vat_required/__manifest__.py new file mode 100644 index 0000000000..9556e791e4 --- /dev/null +++ b/website_sale_vat_required/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2015 Agile Business Group sagl () +# Copyright 2017 Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "e-commerce required VAT", + "summary": "VAT number required in checkout form", + "version": "19.0.1.0.0", + "category": "Website", + "author": "Agile Business Group, Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/e-commerce", + "license": "AGPL-3", + "depends": ["website_sale", "base_vat"], + "installable": True, + "auto_install": False, + "assets": { + "web.assets_tests": [ + "website_sale_vat_required/static/tests/tours/website_sale_vat_required.esm.js", + ], + }, +} diff --git a/website_sale_vat_required/controllers/__init__.py b/website_sale_vat_required/controllers/__init__.py new file mode 100644 index 0000000000..0548325de4 --- /dev/null +++ b/website_sale_vat_required/controllers/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2015 Lorenzo Battistini +# Copyright 2017 Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import main diff --git a/website_sale_vat_required/controllers/main.py b/website_sale_vat_required/controllers/main.py new file mode 100644 index 0000000000..734cdd8d04 --- /dev/null +++ b/website_sale_vat_required/controllers/main.py @@ -0,0 +1,26 @@ +# Copyright 2015 Agile Business Group sagl () +# Copyright 2017 Jairo Llopis +# Copyright 2025 Carlos Lopez - Tecnativa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteSale(WebsiteSale): + def _get_mandatory_billing_address_fields(self, country_sudo): + field_names = super()._get_mandatory_billing_address_fields(country_sudo) + if "vat" not in field_names: + field_names |= {"vat"} + return field_names + + def _prepare_address_form_values(self, *args, **kwargs): + rendering_values = super()._prepare_address_form_values(*args, **kwargs) + + address_type = kwargs.get("address_type") + use_delivery_as_billing = kwargs.get("use_delivery_as_billing", False) + + rendering_values["show_vat"] = ( + address_type == "billing" or use_delivery_as_billing + ) + + return rendering_values diff --git a/website_sale_vat_required/i18n/ca.po b/website_sale_vat_required/i18n/ca.po new file mode 100644 index 0000000000..e69de29bb2 diff --git a/website_sale_vat_required/i18n/es.po b/website_sale_vat_required/i18n/es.po new file mode 100644 index 0000000000..a817e41d03 --- /dev/null +++ b/website_sale_vat_required/i18n/es.po @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_vat_required +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2018-11-13 09:15+0000\n" +"Last-Translator: David Vidal \n" +"Language-Team: none\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.2.2\n" + +#~ msgid "TIN / VAT" +#~ msgstr "NIF" diff --git a/website_sale_vat_required/i18n/it.po b/website_sale_vat_required/i18n/it.po new file mode 100644 index 0000000000..73388557f6 --- /dev/null +++ b/website_sale_vat_required/i18n/it.po @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\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" diff --git a/website_sale_vat_required/i18n/pt_BR.po b/website_sale_vat_required/i18n/pt_BR.po new file mode 100644 index 0000000000..f3cdc6359e --- /dev/null +++ b/website_sale_vat_required/i18n/pt_BR.po @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: pt_BR\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" diff --git a/website_sale_vat_required/i18n/website_sale_vat_required.pot b/website_sale_vat_required/i18n/website_sale_vat_required.pot new file mode 100644 index 0000000000..aadee09bfe --- /dev/null +++ b/website_sale_vat_required/i18n/website_sale_vat_required.pot @@ -0,0 +1,13 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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" diff --git a/website_sale_vat_required/pyproject.toml b/website_sale_vat_required/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/website_sale_vat_required/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/website_sale_vat_required/readme/CONTRIBUTORS.md b/website_sale_vat_required/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..d15ea4884b --- /dev/null +++ b/website_sale_vat_required/readme/CONTRIBUTORS.md @@ -0,0 +1,9 @@ +- Lorenzo Battistini \<\> + +- [Tecnativa](https://www.tecnativa.com): + + > - Jairo Llopis + > - Ernesto Tejeda + > - Carlos Lopez + +- Abraham Anes \<\> diff --git a/website_sale_vat_required/readme/DESCRIPTION.md b/website_sale_vat_required/readme/DESCRIPTION.md new file mode 100644 index 0000000000..9eec08e2da --- /dev/null +++ b/website_sale_vat_required/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends checkout e-commerce form in order to force user to +fill 'VAT number' field. diff --git a/website_sale_vat_required/readme/USAGE.md b/website_sale_vat_required/readme/USAGE.md new file mode 100644 index 0000000000..f470f7f089 --- /dev/null +++ b/website_sale_vat_required/readme/USAGE.md @@ -0,0 +1,6 @@ +To use this module, you need to: + +1. Buy something from your e-commerce +2. Go to checkout page. +3. Try to checkout without specifying a VAT, or using a wrong one. +4. You will get an error. diff --git a/website_sale_vat_required/static/description/icon.png b/website_sale_vat_required/static/description/icon.png new file mode 100644 index 0000000000..0c66fd6919 Binary files /dev/null and b/website_sale_vat_required/static/description/icon.png differ diff --git a/website_sale_vat_required/static/description/index.html b/website_sale_vat_required/static/description/index.html new file mode 100644 index 0000000000..dc366c6da5 --- /dev/null +++ b/website_sale_vat_required/static/description/index.html @@ -0,0 +1,454 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

e-commerce required VAT

+ +

Beta License: AGPL-3 OCA/e-commerce Translate me on Weblate Try me on Runboat

+

This module extends checkout e-commerce form in order to force user to +fill ‘VAT number’ field.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Buy something from your e-commerce
  2. +
  3. Go to checkout page.
  4. +
  5. Try to checkout without specifying a VAT, or using a wrong one.
  6. +
  7. You will get an error.
  8. +
+
+
+

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

+
    +
  • Agile Business Group
  • +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

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/e-commerce project on GitHub.

+

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

+
+
+
+
+ + diff --git a/website_sale_vat_required/static/tests/tours/website_sale_vat_required.esm.js b/website_sale_vat_required/static/tests/tours/website_sale_vat_required.esm.js new file mode 100644 index 0000000000..182b7b3b61 --- /dev/null +++ b/website_sale_vat_required/static/tests/tours/website_sale_vat_required.esm.js @@ -0,0 +1,83 @@ +/* Copyright 2025 Carlos Lopez - Tecnativa + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + */ + +/** @odoo-module **/ + +import * as tourUtils from "@website_sale/js/tours/tour_utils"; +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("website_sale_vat_required_tour", { + test: true, + url: "/shop", + steps: () => [ + { + content: "Open product page", + trigger: "a:contains('Test Product Vat Required')", + run: "click", + expectUnloadPage: true, + }, + { + content: "Add product to cart", + trigger: "#add_to_cart", + run: "click", + }, + tourUtils.goToCart({quantity: 1}), + tourUtils.goToCheckout(), + { + content: "Set country", + trigger: 'select[name="country_id"]', + run: "selectByLabel Afghanistan", + }, + { + content: "Set name", + trigger: 'input[name="name"]', + run: "edit Mr. Test", + }, + { + content: "Set email", + trigger: 'input[name="email"]', + run: "edit test@test.com", + }, + { + content: "Set phone", + trigger: 'input[name="phone"]', + run: "edit 11111111", + }, + { + content: "Set street", + trigger: 'input[name="street"]', + run: "edit Test Street", + }, + { + content: "Set city", + trigger: 'input[name="city"]', + run: "edit Test City", + }, + { + content: "Set ZIP", + trigger: 'input[name="zip"]', + run: "edit 10000", + }, + { + content: "Submit address", + trigger: 'a[name="website_sale_main_button"]', + run: "click", + }, + { + content: "VAT must be required", + trigger: 'input[name="vat"].is-invalid', + }, + { + content: "Fill VAT", + trigger: 'input[name="vat"]', + run: "edit VAT123", + }, + { + content: "Submit again", + trigger: 'a[name="website_sale_main_button"]', + run: "click", + expectUnloadPage: true, + }, + ], +}); diff --git a/website_sale_vat_required/tests/__init__.py b/website_sale_vat_required/tests/__init__.py new file mode 100644 index 0000000000..fac8456883 --- /dev/null +++ b/website_sale_vat_required/tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2019 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import test_website_sale_vat_required diff --git a/website_sale_vat_required/tests/test_website_sale_vat_required.py b/website_sale_vat_required/tests/test_website_sale_vat_required.py new file mode 100644 index 0000000000..aff9de8167 --- /dev/null +++ b/website_sale_vat_required/tests/test_website_sale_vat_required.py @@ -0,0 +1,22 @@ +# Copyright 2019 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import tagged +from odoo.tests.common import HttpCase + + +@tagged("post_install", "-at_install") +class TestWebsiteSaleVatRequired(HttpCase): + def setUp(self): + super().setUp() + self.product = self.env["product.template"].create( + { + "name": "Test Product Vat Required", + "is_published": True, + "website_sequence": 1, + "type": "consu", + "list_price": 10.0, + } + ) + + def test_website_sale_vat_required(self): + self.start_tour("/shop", "website_sale_vat_required_tour")