diff --git a/README.md b/README.md index b86e9eb0a8..b2336edcfb 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ addon | version | maintainers | summary [website_sale_stock_list_preview](website_sale_stock_list_preview/) | 16.0.1.0.1 | | Show the stock of products on the product previews [website_sale_stock_provisioning_date](website_sale_stock_provisioning_date/) | 16.0.1.0.0 | | Display provisioning date for a product in shop online [website_sale_suggest_create_account](website_sale_suggest_create_account/) | 16.0.1.1.0 | | Suggest users to create an account when buying in the website +[website_sale_tax_toggle](website_sale_tax_toggle/) | 16.0.1.0.0 | | Allow display price in Shop with or without taxes [website_sale_vat_required](website_sale_vat_required/) | 16.0.1.0.1 | | VAT number required in checkout form [website_sale_wishlist_hide_price](website_sale_wishlist_hide_price/) | 16.0.1.0.0 | | Hide product prices on the shop [website_sale_wishlist_keep](website_sale_wishlist_keep/) | 16.0.1.0.1 | | Allows to add products to my cart but keep it in my wishlist" diff --git a/setup/_metapackage/VERSION.txt b/setup/_metapackage/VERSION.txt index ed9edb18a4..72c0783c4f 100644 --- a/setup/_metapackage/VERSION.txt +++ b/setup/_metapackage/VERSION.txt @@ -1 +1 @@ -16.0.20240719.0 \ No newline at end of file +16.0.20240821.0 \ No newline at end of file diff --git a/setup/_metapackage/setup.py b/setup/_metapackage/setup.py index 2ab3b17205..b7cc7c215c 100644 --- a/setup/_metapackage/setup.py +++ b/setup/_metapackage/setup.py @@ -34,6 +34,7 @@ 'odoo-addon-website_sale_stock_list_preview>=16.0dev,<16.1dev', 'odoo-addon-website_sale_stock_provisioning_date>=16.0dev,<16.1dev', 'odoo-addon-website_sale_suggest_create_account>=16.0dev,<16.1dev', + 'odoo-addon-website_sale_tax_toggle>=16.0dev,<16.1dev', 'odoo-addon-website_sale_vat_required>=16.0dev,<16.1dev', 'odoo-addon-website_sale_wishlist_hide_price>=16.0dev,<16.1dev', 'odoo-addon-website_sale_wishlist_keep>=16.0dev,<16.1dev', diff --git a/setup/website_sale_tax_toggle/odoo/addons/website_sale_tax_toggle b/setup/website_sale_tax_toggle/odoo/addons/website_sale_tax_toggle new file mode 120000 index 0000000000..9a10a5eb14 --- /dev/null +++ b/setup/website_sale_tax_toggle/odoo/addons/website_sale_tax_toggle @@ -0,0 +1 @@ +../../../../website_sale_tax_toggle \ No newline at end of file diff --git a/setup/website_sale_tax_toggle/setup.py b/setup/website_sale_tax_toggle/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/website_sale_tax_toggle/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_sale_tax_toggle/README.rst b/website_sale_tax_toggle/README.rst new file mode 100644 index 0000000000..5d66959ecf --- /dev/null +++ b/website_sale_tax_toggle/README.rst @@ -0,0 +1,87 @@ +======================= +Website Sale Tax Toggle +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c270670417ab964514fb4b13777bc5c450f9c199b878c31ca9509e9da8f9c4fc + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fe--commerce-lightgray.png?logo=github + :target: https://github.com/OCA/e-commerce/tree/16.0/website_sale_tax_toggle + :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-16-0/e-commerce-16-0-website_sale_tax_toggle + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of website sale module adding a toggle +button to allow to user selects view prices with taxes included or without taxes. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to Website Shop. +#. Now you can see a taxes toggle button to select prices with taxes included or + without taxes. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Carlos Dauden + * Sergio Teruel + +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_tax_toggle/__init__.py b/website_sale_tax_toggle/__init__.py new file mode 100644 index 0000000000..df9b9c226b --- /dev/null +++ b/website_sale_tax_toggle/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import controllers +from . import models diff --git a/website_sale_tax_toggle/__manifest__.py b/website_sale_tax_toggle/__manifest__.py new file mode 100644 index 0000000000..899e3453c7 --- /dev/null +++ b/website_sale_tax_toggle/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2020 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Website Sale Tax Toggle", + "summary": "Allow display price in Shop with or without taxes", + "version": "16.0.1.0.0", + "development_status": "Beta", + "category": "Website", + "website": "https://github.com/OCA/e-commerce", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["website_sale"], + "data": ["views/templates.xml"], + "assets": { + "web.assets_frontend": [ + "/website_sale_tax_toggle/static/src/js/website_sale_tax_toggle.esm.js", + "/website_sale_tax_toggle/static/src/scss/website_sale_tax_toggle.scss", + ], + "web.assets_tests": [ + "/website_sale_tax_toggle/static/src/js/website_sale_tax_toggle_tour.esm.js" + ], + }, +} diff --git a/website_sale_tax_toggle/controllers/__init__.py b/website_sale_tax_toggle/controllers/__init__.py new file mode 100644 index 0000000000..dea930adca --- /dev/null +++ b/website_sale_tax_toggle/controllers/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import main diff --git a/website_sale_tax_toggle/controllers/main.py b/website_sale_tax_toggle/controllers/main.py new file mode 100644 index 0000000000..5aae844021 --- /dev/null +++ b/website_sale_tax_toggle/controllers/main.py @@ -0,0 +1,17 @@ +# Copyright 2020 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import http +from odoo.http import request + +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteSaleTaxToggle(WebsiteSale): + @http.route(["/website/tax_toggle"], type="json", auth="public", website=True) + def tax_toggle(self): + # Create a session variable + request.session["tax_toggle_taxed"] = not request.session.get( + "tax_toggle_taxed", False + ) + return request.session["tax_toggle_taxed"] diff --git a/website_sale_tax_toggle/i18n/ca.po b/website_sale_tax_toggle/i18n/ca.po new file mode 100644 index 0000000000..f5eef412ca --- /dev/null +++ b/website_sale_tax_toggle/i18n/ca.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_tax_toggle +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-01-20 20:45+0000\n" +"Last-Translator: claudiagn \n" +"Language-Team: none\n" +"Language: ca\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.3.2\n" + +#. module: website_sale_tax_toggle +#: model_terms:ir.ui.view,arch_db:website_sale_tax_toggle.tax_toggle_template +msgid "" +"\n" +" Show prices with taxes included" +msgstr "" +"\n" +" Mostra preus amb taxes incloses" + +#. module: website_sale_tax_toggle +#: model:ir.model,name:website_sale_tax_toggle.model_res_users +msgid "Users" +msgstr "Usuaris" diff --git a/website_sale_tax_toggle/i18n/es.po b/website_sale_tax_toggle/i18n/es.po new file mode 100644 index 0000000000..e92d2867a7 --- /dev/null +++ b/website_sale_tax_toggle/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_tax_toggle +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-07-07 14:17+0000\n" +"PO-Revision-Date: 2020-07-07 16:19+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.6\n" + +#. module: website_sale_tax_toggle +#: model_terms:ir.ui.view,arch_db:website_sale_tax_toggle.tax_toggle_template +msgid "" +"\n" +" Show prices with taxes included" +msgstr "" +"\n" +" Mostrar precios con impuestos incluidos" + +#. module: website_sale_tax_toggle +#: model:ir.model,name:website_sale_tax_toggle.model_res_users +msgid "Users" +msgstr "Usuarios" diff --git a/website_sale_tax_toggle/i18n/fr.po b/website_sale_tax_toggle/i18n/fr.po new file mode 100644 index 0000000000..9d9323dd26 --- /dev/null +++ b/website_sale_tax_toggle/i18n/fr.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_tax_toggle +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-11-23 15:36+0000\n" +"Last-Translator: Yann Papouin \n" +"Language-Team: none\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" +"X-Generator: Weblate 3.10\n" + +#. module: website_sale_tax_toggle +#: model_terms:ir.ui.view,arch_db:website_sale_tax_toggle.tax_toggle_template +msgid "" +"\n" +" Show prices with taxes included" +msgstr "" +"\n" +" Afficher les prix TTC" + +#. module: website_sale_tax_toggle +#: model:ir.model,name:website_sale_tax_toggle.model_res_users +msgid "Users" +msgstr "Utilisateurs" diff --git a/website_sale_tax_toggle/i18n/nl.po b/website_sale_tax_toggle/i18n/nl.po new file mode 100644 index 0000000000..d875b9d453 --- /dev/null +++ b/website_sale_tax_toggle/i18n/nl.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_tax_toggle +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-04-05 18:46+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: nl\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.3.2\n" + +#. module: website_sale_tax_toggle +#: model_terms:ir.ui.view,arch_db:website_sale_tax_toggle.tax_toggle_template +msgid "" +"\n" +" Show prices with taxes included" +msgstr "" +"\n" +" Prijzen weergeven inclusief BTW" + +#. module: website_sale_tax_toggle +#: model:ir.model,name:website_sale_tax_toggle.model_res_users +msgid "Users" +msgstr "Gebruikers" diff --git a/website_sale_tax_toggle/i18n/website_sale_tax_toggle.pot b/website_sale_tax_toggle/i18n/website_sale_tax_toggle.pot new file mode 100644 index 0000000000..1fe1a2d714 --- /dev/null +++ b/website_sale_tax_toggle/i18n/website_sale_tax_toggle.pot @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_tax_toggle +# +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_sale_tax_toggle +#: model_terms:ir.ui.view,arch_db:website_sale_tax_toggle.tax_toggle_template +msgid "" +"\n" +" Show prices with taxes included" +msgstr "" + +#. module: website_sale_tax_toggle +#: model:ir.model,name:website_sale_tax_toggle.model_res_users +msgid "User" +msgstr "" diff --git a/website_sale_tax_toggle/models/__init__.py b/website_sale_tax_toggle/models/__init__.py new file mode 100644 index 0000000000..0cedff9216 --- /dev/null +++ b/website_sale_tax_toggle/models/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2020 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import res_users diff --git a/website_sale_tax_toggle/models/res_users.py b/website_sale_tax_toggle/models/res_users.py new file mode 100644 index 0000000000..0a76b016bb --- /dev/null +++ b/website_sale_tax_toggle/models/res_users.py @@ -0,0 +1,35 @@ +# Copyright 2020 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, models +from odoo.http import request +from odoo.tools import ormcache + + +class ResUsers(models.Model): + _inherit = "res.users" + + @api.model + def has_group(self, group_ext_id): + tax_included = "account.group_show_line_subtotals_tax_included" + tax_excluded = "account.group_show_line_subtotals_tax_excluded" + if ( + self.env.context.get("website_id") + and group_ext_id in [tax_included, tax_excluded] + and not self.env.context.get("skip_tax_toggle_check") + ): + taxed = request.session.get( + "tax_toggle_taxed", + self.env.user.with_context(skip_tax_toggle_check=True).has_group( + tax_included + ), + ) + return group_ext_id != (tax_excluded if taxed else tax_included) + return super().has_group(group_ext_id) + + # HACK: To clear cache called from res.users write method + @api.model + @ormcache("self._uid", "group_ext_id") + def _has_group(self, group_ext_id): + return super()._has_group(group_ext_id) + + has_group.clear_cache = _has_group.clear_cache diff --git a/website_sale_tax_toggle/readme/CONTRIBUTORS.rst b/website_sale_tax_toggle/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..22e2c95561 --- /dev/null +++ b/website_sale_tax_toggle/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Carlos Dauden + * Sergio Teruel diff --git a/website_sale_tax_toggle/readme/DESCRIPTION.rst b/website_sale_tax_toggle/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..94fc360ea4 --- /dev/null +++ b/website_sale_tax_toggle/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module extends the functionality of website sale module adding a toggle +button to allow to user selects view prices with taxes included or without taxes. diff --git a/website_sale_tax_toggle/readme/USAGE.rst b/website_sale_tax_toggle/readme/USAGE.rst new file mode 100644 index 0000000000..28b8545171 --- /dev/null +++ b/website_sale_tax_toggle/readme/USAGE.rst @@ -0,0 +1,3 @@ +#. Go to Website Shop. +#. Now you can see a taxes toggle button to select prices with taxes included or + without taxes. diff --git a/website_sale_tax_toggle/static/description/icon.png b/website_sale_tax_toggle/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/website_sale_tax_toggle/static/description/icon.png differ diff --git a/website_sale_tax_toggle/static/description/index.html b/website_sale_tax_toggle/static/description/index.html new file mode 100644 index 0000000000..703b9980a2 --- /dev/null +++ b/website_sale_tax_toggle/static/description/index.html @@ -0,0 +1,440 @@ + + + + + +Website Sale Tax Toggle + + + +
+

Website Sale Tax Toggle

+ + +

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

+

This module extends the functionality of website sale module adding a toggle +button to allow to user selects view prices with taxes included or without taxes.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Website Shop.
  2. +
  3. Now you can see a taxes toggle button to select prices with taxes included or +without taxes.
  4. +
+
+
+

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

+
    +
  • 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_tax_toggle/static/src/js/website_sale_tax_toggle.esm.js b/website_sale_tax_toggle/static/src/js/website_sale_tax_toggle.esm.js new file mode 100644 index 0000000000..8b3d43c284 --- /dev/null +++ b/website_sale_tax_toggle/static/src/js/website_sale_tax_toggle.esm.js @@ -0,0 +1,24 @@ +/** @odoo-module **/ + +/* Copyright 2020 Sergio Teruel + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ + +import {browser} from "@web/core/browser/browser"; +import publicWidget from "web.public.widget"; + +publicWidget.registry.tax_toggle_button = publicWidget.Widget.extend({ + selector: ".js_tax_toggle_management", + events: { + "click .js_tax_toggle_btn": "_onPublishBtnClick", + }, + _onPublishBtnClick: function (ev) { + ev.preventDefault(); + const $data = $(ev.currentTarget).parents(".js_tax_toggle_management:first"); + this._rpc({ + route: $data.data("controller"), + }).then(function (result) { + $data.find("input").prop("checked", result); + browser.location.reload(); + }); + }, +}); diff --git a/website_sale_tax_toggle/static/src/js/website_sale_tax_toggle_tour.esm.js b/website_sale_tax_toggle/static/src/js/website_sale_tax_toggle_tour.esm.js new file mode 100644 index 0000000000..944377b7e8 --- /dev/null +++ b/website_sale_tax_toggle/static/src/js/website_sale_tax_toggle_tour.esm.js @@ -0,0 +1,43 @@ +/** @odoo-module **/ +/* Copyright 2020 Sergio Teruel + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ + +import tour from "web_tour.tour"; + +// Notice that it's important targeting the price as `span .oe_currency_value` +// or `.oe_price .oe_currency_value` to make sure this test is compatible +// with website_sale_b2x_alt_price module in this same repo. +const steps = [ + { + content: "Toggle tax button click from list page", + trigger: ".js_tax_toggle_btn", + extra_trigger: + ".oe_product_cart:contains('Product test tax toggle') span .oe_currency_value:containsExact('750.00')", + }, + { + content: "Enter the product page", + trigger: + ".oe_product_cart:has(span .oe_currency_value:containsExact('862.50')) a:contains('Product test tax toggle')", + extra_trigger: ".o_switch_danger:has(input:checked)", + }, + { + content: "Toggle tax button click from product page", + trigger: ".js_tax_toggle_btn", + extra_trigger: + "#product_details .oe_price .oe_currency_value:containsExact('862.50')", + }, + { + content: "Check the product price is back to what it should", + trigger: + "#product_details .oe_price .oe_currency_value:containsExact('750.00')", + extra_trigger: ".o_switch_danger:has(input:not(:checked))", + }, +]; +tour.register( + "website_sale_tax_toggle", + { + url: "/shop", + test: true, + }, + steps +); diff --git a/website_sale_tax_toggle/static/src/scss/website_sale_tax_toggle.scss b/website_sale_tax_toggle/static/src/scss/website_sale_tax_toggle.scss new file mode 100644 index 0000000000..c74ed4dfb1 --- /dev/null +++ b/website_sale_tax_toggle/static/src/scss/website_sale_tax_toggle.scss @@ -0,0 +1,60 @@ +// This styles has been added from addons/website/static/src/scss/web_editor.ui.scss +// to apply styles for public user too. +// INPUTS +$o-we-md-ease: cubic-bezier(0.19, 1, 0.22, 1) !default; +$o-we-bg-color: #f7f7f7 !default; +$o-we-switch-size: 2ex !default; +$o-we-switch-inactive-color: #f7f7f7 !default; +.o_switch { + display: flex; + align-items: center; + font-weight: normal; + cursor: pointer; + + > input { + display: none; + + + span { + background-color: $o-we-switch-inactive-color; + box-shadow: inset 0 0 0px 1px darken($o-we-switch-inactive-color, 10%); + border-radius: 100rem; + height: $o-we-switch-size; + width: $o-we-switch-size * 1.8; + margin-right: 0.5em; + display: inline-block; + transition: all 0.3s $o-we-md-ease; + + &:after { + content: ""; + background: $o-we-bg-color; + display: block; + width: $o-we-switch-size - 0.2; + height: $o-we-switch-size - 0.2; + margin-top: 0.1ex; + margin-left: 0.1ex; + border-radius: 100rem; + transition: all 0.3s $o-we-md-ease; + box-shadow: 0 1px 1px darken($o-we-switch-inactive-color, 35%), + inset 0 0 0 1px lighten($o-we-switch-inactive-color, 10%); + } + } + + &:checked + span { + box-shadow: none; + background: $o-we-color-success; + + &:after { + margin-left: ($o-we-switch-size * 1.8 - $o-we-switch-size) + 0.1; + } + } + } + + &.o_switch_danger { + > input { + &:not(:checked) + span { + box-shadow: none; + background: $o-we-color-danger; + } + } + } +} diff --git a/website_sale_tax_toggle/tests/__init__.py b/website_sale_tax_toggle/tests/__init__.py new file mode 100644 index 0000000000..f4f133d263 --- /dev/null +++ b/website_sale_tax_toggle/tests/__init__.py @@ -0,0 +1 @@ +from . import test_website_sale_tax_toggle diff --git a/website_sale_tax_toggle/tests/test_website_sale_tax_toggle.py b/website_sale_tax_toggle/tests/test_website_sale_tax_toggle.py new file mode 100644 index 0000000000..74b51f5b2b --- /dev/null +++ b/website_sale_tax_toggle/tests/test_website_sale_tax_toggle.py @@ -0,0 +1,49 @@ +# Copyright 2020 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import tagged +from odoo.tests.common import HttpCase + +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + + +@tagged("post_install", "-at_install") +class WebsiteSaleTaxesToggleHttpCase(HttpCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + # Get company for Mitchel Admin user + cls.user_admin = cls.env.ref("base.user_admin") + user_company = cls.user_admin.company_id + cls.tax = cls.env["account.tax"].create( + { + "name": "Taxes toggle test tax", + "amount_type": "percent", + "amount": 15, + "type_tax_use": "sale", + "company_id": user_company.id, + } + ) + cls.product_template = cls.env["product.template"].create( + { + "name": "Product test tax toggle", + "list_price": 750.00, + "taxes_id": [(6, 0, cls.tax.ids)], + "website_published": True, + "website_sequence": 9999, + } + ) + pricelist = cls.env["product.pricelist"].create( + {"name": "Price list for tests", "currency_id": user_company.currency_id.id} + ) + cls.env.user.partner_id.property_product_pricelist = pricelist + # To avoid currency converter + cls.env["res.currency.rate"].search([]).write({"rate": 1}) + + def test_ui_website(self): + """Test frontend tour.""" + self.start_tour( + url_path="/shop", + tour_name="website_sale_tax_toggle", + login="admin", + ) diff --git a/website_sale_tax_toggle/views/templates.xml b/website_sale_tax_toggle/views/templates.xml new file mode 100644 index 0000000000..6512cc655d --- /dev/null +++ b/website_sale_tax_toggle/views/templates.xml @@ -0,0 +1,82 @@ + + + + + + + + + + +