diff --git a/setup/website_product_configurator_hide_price/odoo/addons/website_product_configurator_hide_price b/setup/website_product_configurator_hide_price/odoo/addons/website_product_configurator_hide_price new file mode 120000 index 000000000..3bdb44562 --- /dev/null +++ b/setup/website_product_configurator_hide_price/odoo/addons/website_product_configurator_hide_price @@ -0,0 +1 @@ +../../../../website_product_configurator_hide_price \ No newline at end of file diff --git a/setup/website_product_configurator_hide_price/setup.py b/setup/website_product_configurator_hide_price/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/website_product_configurator_hide_price/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..8cace97cc --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +# https://github.com/OCA/product-configurator/pull/103 +odoo-addon-website_product_configurator @ git+https://github.com/OCA/product-configurator.git@refs/pull/103/head#subdirectory=setup/website_product_configurator diff --git a/website_product_configurator_hide_price/README.rst b/website_product_configurator_hide_price/README.rst new file mode 100644 index 000000000..c63afa020 --- /dev/null +++ b/website_product_configurator_hide_price/README.rst @@ -0,0 +1,86 @@ +========================================== +Hide price in Website Product Configurator +========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:06008a324950423511f92dc903e8ad2f711d75a8519adc6f08dd08b08d86d426 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fproduct--configurator-lightgray.png?logo=github + :target: https://github.com/OCA/product-configurator/tree/16.0/website_product_configurator_hide_price + :alt: OCA/product-configurator +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/product-configurator-16-0/product-configurator-16-0-website_product_configurator_hide_price + :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/product-configurator&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Hide price of configurable products as configured in `website_sale_hide_price`. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Aion Tech + +Contributors +~~~~~~~~~~~~ + +* `Aion Tech `_: + + * Simone Rubino + +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-SirAionTech| image:: https://github.com/SirAionTech.png?size=40px + :target: https://github.com/SirAionTech + :alt: SirAionTech + +Current `maintainer `__: + +|maintainer-SirAionTech| + +This module is part of the `OCA/product-configurator `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_product_configurator_hide_price/__init__.py b/website_product_configurator_hide_price/__init__.py new file mode 100644 index 000000000..a864e7c4a --- /dev/null +++ b/website_product_configurator_hide_price/__init__.py @@ -0,0 +1 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). diff --git a/website_product_configurator_hide_price/__manifest__.py b/website_product_configurator_hide_price/__manifest__.py new file mode 100644 index 000000000..20bd5a180 --- /dev/null +++ b/website_product_configurator_hide_price/__manifest__.py @@ -0,0 +1,29 @@ +# Copyright 2024 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Hide price in Website Product Configurator", + "summary": "Hide price in Product Configurator", + "category": "website", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "website": "https://github.com/OCA/product-configurator", + "author": "Aion Tech, Odoo Community Association (OCA)", + "maintainers": [ + "SirAionTech", + ], + "depends": [ + "website_product_configurator", + "website_sale_hide_price", + ], + "auto_install": True, + "data": [ + "views/templates.xml", + ], + "assets": { + "web.assets_tests": [ + "website_product_configurator_hide_price/static/tests/tours/show_message.esm.js", + "website_product_configurator_hide_price/static/tests/tours/show_price.esm.js", + ], + }, +} diff --git a/website_product_configurator_hide_price/readme/CONTRIBUTORS.rst b/website_product_configurator_hide_price/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..6afa1541b --- /dev/null +++ b/website_product_configurator_hide_price/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Aion Tech `_: + + * Simone Rubino diff --git a/website_product_configurator_hide_price/readme/DESCRIPTION.rst b/website_product_configurator_hide_price/readme/DESCRIPTION.rst new file mode 100644 index 000000000..4a85f6c1f --- /dev/null +++ b/website_product_configurator_hide_price/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Hide price of configurable products as configured in `website_sale_hide_price`. diff --git a/website_product_configurator_hide_price/static/description/index.html b/website_product_configurator_hide_price/static/description/index.html new file mode 100644 index 000000000..1d48af5ef --- /dev/null +++ b/website_product_configurator_hide_price/static/description/index.html @@ -0,0 +1,425 @@ + + + + + +Hide price in Website Product Configurator + + + +
+

Hide price in Website Product Configurator

+ + +

Beta License: AGPL-3 OCA/product-configurator Translate me on Weblate Try me on Runboat

+

Hide price of configurable products as configured in website_sale_hide_price.

+

Table of contents

+ +
+

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

+
    +
  • Aion Tech
  • +
+
+
+

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.

+

Current maintainer:

+

SirAionTech

+

This module is part of the OCA/product-configurator project on GitHub.

+

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

+
+
+
+ + diff --git a/website_product_configurator_hide_price/static/tests/tours/show_message.esm.js b/website_product_configurator_hide_price/static/tests/tours/show_message.esm.js new file mode 100644 index 000000000..5092559e0 --- /dev/null +++ b/website_product_configurator_hide_price/static/tests/tours/show_message.esm.js @@ -0,0 +1,17 @@ +/** @odoo-module **/ +import tour from "web_tour.tour"; + +tour.register( + "website_product_configurator_hide_price.show_message", + { + test: true, + }, + [ + { + content: "Check Message is shown", + trigger: "div[class='alert alert-info'] > span:contains('Price is hidden')", + // eslint-disable-next-line no-empty-function + run: () => {}, + }, + ] +); diff --git a/website_product_configurator_hide_price/static/tests/tours/show_price.esm.js b/website_product_configurator_hide_price/static/tests/tours/show_price.esm.js new file mode 100644 index 000000000..7a3c5a38b --- /dev/null +++ b/website_product_configurator_hide_price/static/tests/tours/show_price.esm.js @@ -0,0 +1,17 @@ +/** @odoo-module **/ +import tour from "web_tour.tour"; + +tour.register( + "website_product_configurator_hide_price.show_price", + { + test: true, + }, + [ + { + content: "Check Price is shown", + trigger: ".js_main_product .oe_price", + // eslint-disable-next-line no-empty-function + run: () => {}, + }, + ] +); diff --git a/website_product_configurator_hide_price/tests/__init__.py b/website_product_configurator_hide_price/tests/__init__.py new file mode 100644 index 000000000..52946533d --- /dev/null +++ b/website_product_configurator_hide_price/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_hide_price diff --git a/website_product_configurator_hide_price/tests/test_hide_price.py b/website_product_configurator_hide_price/tests/test_hide_price.py new file mode 100644 index 000000000..b2f482a0d --- /dev/null +++ b/website_product_configurator_hide_price/tests/test_hide_price.py @@ -0,0 +1,104 @@ +# Copyright 2024 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import operator +from functools import reduce + +from odoo.tests import HttpCase, tagged +from odoo.tools import mute_logger + +# Found no way to wrap this nicely enough for linters +from odoo.addons.website_product_configurator.tests.test_website_product_configurator_values import ( # noqa: B950 + TestProductConfiguratorValues, +) + +MODULE_NAME = "website_product_configurator_hide_price" +TEST_BROWSER_PATH = ( + "odoo.addons.%s.tests.test_hide_price.TestHidePrice.browser" % MODULE_NAME +) + + +@tagged("post_install", "-at_install") +class TestHidePrice(HttpCase, TestProductConfiguratorValues): + def test_tour_hide_price(self): + """If a configured product has `website_hide_price` enabled, + the price is hidden and the message is shown. + """ + admin_user = self.env.ref("base.user_admin") + + session = self.session_id + session.user_id = admin_user + pavs_xmlids = [ + "product_configurator.product_attribute_value_gasoline", + "product_configurator.product_attribute_value_218i", + "product_configurator.product_attribute_value_steptronic", + "product_configurator.product_attribute_value_silver", + "product_configurator.product_attribute_value_rims_378", + "product_configurator.product_attribute_value_tapistry_black", + "product_configurator.product_attribute_value_sport_line", + "product_configurator.product_attribute_value_armrest", + ] + pavs_list = [self.env.ref(xmlid) for xmlid in pavs_xmlids] + session.value_ids = reduce(operator.or_, pavs_list) + session.action_confirm() + product = session.product_id + product.website_hide_price = True + product.website_hide_price_message = "Price is hidden" + + session_url = "/product_configurator/product/%s" % session.id + self.start_tour( + session_url, + "website_product_configurator_hide_price.show_message", + login=admin_user.login, + ) + # There is no way to assert that a node is missing in tours, + # so we check that the tour fails. + with self.assertRaises(AssertionError) as ae, mute_logger(TEST_BROWSER_PATH): + self.start_tour( + session_url, + "website_product_configurator_hide_price.show_price", + login=admin_user.login, + ) + exc_message = ae.exception.args[0] + self.assertIn("failed at step Check Price is shown", exc_message) + + def test_tour_show_price(self): + """If a configured product has `website_hide_price` disabled, + the price is shown and the message is hidden. + """ + admin_user = self.env.ref("base.user_admin") + + session = self.session_id + session.user_id = admin_user + pavs_xmlids = [ + "product_configurator.product_attribute_value_gasoline", + "product_configurator.product_attribute_value_218i", + "product_configurator.product_attribute_value_steptronic", + "product_configurator.product_attribute_value_silver", + "product_configurator.product_attribute_value_rims_378", + "product_configurator.product_attribute_value_tapistry_black", + "product_configurator.product_attribute_value_sport_line", + "product_configurator.product_attribute_value_armrest", + ] + pavs_list = [self.env.ref(xmlid) for xmlid in pavs_xmlids] + session.value_ids = reduce(operator.or_, pavs_list) + session.action_confirm() + product = session.product_id + product.website_hide_price = False + + session_url = "/product_configurator/product/%s" % session.id + self.start_tour( + session_url, + "website_product_configurator_hide_price.show_price", + login=admin_user.login, + ) + # There is no way to assert that a node is missing in tours, + # so we check that the tour fails. + with self.assertRaises(AssertionError) as ae, mute_logger(TEST_BROWSER_PATH): + self.start_tour( + session_url, + "website_product_configurator_hide_price.show_message", + login=admin_user.login, + ) + exc_message = ae.exception.args[0] + self.assertIn("failed at step Check Message is shown", exc_message) diff --git a/website_product_configurator_hide_price/views/templates.xml b/website_product_configurator_hide_price/views/templates.xml new file mode 100644 index 000000000..9fddc263a --- /dev/null +++ b/website_product_configurator_hide_price/views/templates.xml @@ -0,0 +1,105 @@ + + + + + + + + + + +