diff --git a/website_sale_product_attribute_filter_category/README.rst b/website_sale_product_attribute_filter_category/README.rst new file mode 100644 index 0000000000..5a6e4bdd43 --- /dev/null +++ b/website_sale_product_attribute_filter_category/README.rst @@ -0,0 +1,108 @@ +====================================== +Website Sale Attribute Filter Category +====================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d91e21f4d3981c898d053da535ba6d157d4b775b4e6b7d2b56063ca645859ae8 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |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/17.0/website_sale_product_attribute_filter_category + :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-17-0/e-commerce-17-0-website_sale_product_attribute_filter_category + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of website sale module to allow to +group product attributes filter by their categories. Also you can select +if you want display folded or unfolded category in website attribute's +filter. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +- Go to ``Website \> eCommerce \> Products \> Attribute Categories`` and + create one. You can select if you want display it folded or unfolded + in website. +- Go to ``Website \> eCommerce \> Products \> Attributes``, create one + or more with this category and add more than one value for each + attribute. +- Go to ``Website \> eCommerce \> Products \> Products`` and create a + product with this attribute and assign it an attribute value. + +Usage +===== + +- Go to the Website Shop. +- Activate the website editor in the top right corner. +- Under the ``Customize`` tab, locate the ``Attributes`` section and + enable the ``Group by categories`` option. +- You should now see the product attribute filters grouped by + categories. + +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 `__: + + - Sergio Teruel + - Carlos Roca + - Pilar Vargas + - Carlos Lopez + +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_product_attribute_filter_category/__init__.py b/website_sale_product_attribute_filter_category/__init__.py new file mode 100644 index 0000000000..df9b9c226b --- /dev/null +++ b/website_sale_product_attribute_filter_category/__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_product_attribute_filter_category/__manifest__.py b/website_sale_product_attribute_filter_category/__manifest__.py new file mode 100644 index 0000000000..2a7638507d --- /dev/null +++ b/website_sale_product_attribute_filter_category/__manifest__.py @@ -0,0 +1,28 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Website Sale Attribute Filter Category", + "summary": "Allow group attributes in shop by categories", + "version": "17.0.1.0.0", + "development_status": "Production/Stable", + "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_comparison"], + "data": [ + "views/templates.xml", + "views/snippets/snippets.xml", + "views/website_sale_product_attribute_filter_category_view.xml", + ], + "assets": { + "web.assets_frontend": [ + "/website_sale_product_attribute_filter_category/static/src/scss/*.scss", + ], + "web.assets_tests": [ + "/website_sale_product_attribute_filter_category/static/tests/tours/*.esm.js" + ], + }, +} diff --git a/website_sale_product_attribute_filter_category/controllers/__init__.py b/website_sale_product_attribute_filter_category/controllers/__init__.py new file mode 100644 index 0000000000..dea930adca --- /dev/null +++ b/website_sale_product_attribute_filter_category/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_product_attribute_filter_category/controllers/main.py b/website_sale_product_attribute_filter_category/controllers/main.py new file mode 100644 index 0000000000..eab3be4314 --- /dev/null +++ b/website_sale_product_attribute_filter_category/controllers/main.py @@ -0,0 +1,29 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import _, http + +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class ProductAttributeCategory(WebsiteSale): + @http.route() + def shop(self, page=0, category=None, search="", ppg=False, **post): + response = super().shop( + page=page, category=category, search=search, ppg=ppg, **post + ) + # Re-order attributes by their category sequence + response.qcontext["attributes"] = response.qcontext["attributes"].sorted( + lambda x: (x.category_id.sequence, x.id) + ) + # Load all categories, and load a "False" category for attributes that + # has not category and display it under 'Undefined' category + categories = [(False, _("Undefined"), True)] + categories.extend( + (x.id, x.name, x.website_folded) + for x in response.qcontext["attributes"].mapped("category_id") + ) + response.qcontext["attribute_categories"] = categories + response.qcontext["filtered_products"] = False + if search or post.get("attrib", False): + response.qcontext["filtered_products"] = True + return response diff --git a/website_sale_product_attribute_filter_category/i18n/ca.po b/website_sale_product_attribute_filter_category/i18n/ca.po new file mode 100644 index 0000000000..aa163f018a --- /dev/null +++ b/website_sale_product_attribute_filter_category/i18n/ca.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_product_attribute_filter_category +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-03-02 12:17+0000\n" +"Last-Translator: Noel estudillo \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_product_attribute_filter_category +#: model_terms:ir.ui.view,arch_db:website_sale_product_attribute_filter_category.products_attributes_categories +msgid "" +"\n" +" Filters by category" +msgstr "" +"\n" +" Filtra per categoria" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model,name:website_sale_product_attribute_filter_category.model_product_attribute_category +msgid "Product Attribute Category" +msgstr "Categoria d'atribut de producte" + +#. module: website_sale_product_attribute_filter_category +#: code:addons/website_sale_product_attribute_filter_category/controllers/main.py:0 +#, python-format +msgid "Undefined" +msgstr "Indefinit" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model.fields,field_description:website_sale_product_attribute_filter_category.field_product_attribute_category__website_folded +msgid "Website folded" +msgstr "Lloc web plegat" + +#~ msgid "" +#~ "\n" +#~ " Filters by category" +#~ msgstr "" +#~ "\n" +#~ " Filtres per categoria " diff --git a/website_sale_product_attribute_filter_category/i18n/es.po b/website_sale_product_attribute_filter_category/i18n/es.po new file mode 100644 index 0000000000..3aa2009aab --- /dev/null +++ b/website_sale_product_attribute_filter_category/i18n/es.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_product_attribute_filter_category +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-09-17 13:05+0000\n" +"PO-Revision-Date: 2023-07-05 14:08+0000\n" +"Last-Translator: Ivorra78 \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: Weblate 4.17\n" + +#. module: website_sale_product_attribute_filter_category +#: model_terms:ir.ui.view,arch_db:website_sale_product_attribute_filter_category.products_attributes_categories +msgid "" +"\n" +" Filters by category" +msgstr "" +"\n" +" Filtros por categoría" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model,name:website_sale_product_attribute_filter_category.model_product_attribute_category +msgid "Product Attribute Category" +msgstr "Categoría de atributo de producto" + +#. module: website_sale_product_attribute_filter_category +#: code:addons/website_sale_product_attribute_filter_category/controllers/main.py:0 +#, python-format +msgid "Undefined" +msgstr "Indefinido" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model.fields,field_description:website_sale_product_attribute_filter_category.field_product_attribute_category__website_folded +msgid "Website folded" +msgstr "Sitio web plegado" + +#~ msgid "" +#~ "\n" +#~ " Filters by category" +#~ msgstr "" +#~ "\n" +#~ " Filtra por categoría " diff --git a/website_sale_product_attribute_filter_category/i18n/fi.po b/website_sale_product_attribute_filter_category/i18n/fi.po new file mode 100644 index 0000000000..6f563ad28b --- /dev/null +++ b/website_sale_product_attribute_filter_category/i18n/fi.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_product_attribute_filter_category +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-03-16 13:13+0000\n" +"Last-Translator: Retropikzel \n" +"Language-Team: none\n" +"Language: fi\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_product_attribute_filter_category +#: model_terms:ir.ui.view,arch_db:website_sale_product_attribute_filter_category.products_attributes_categories +msgid "" +"\n" +" Filters by category" +msgstr "" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model,name:website_sale_product_attribute_filter_category.model_product_attribute_category +msgid "Product Attribute Category" +msgstr "" + +#. module: website_sale_product_attribute_filter_category +#: code:addons/website_sale_product_attribute_filter_category/controllers/main.py:0 +#, python-format +msgid "Undefined" +msgstr "Määrittelemätön" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model.fields,field_description:website_sale_product_attribute_filter_category.field_product_attribute_category__website_folded +msgid "Website folded" +msgstr "" + +#, fuzzy +#~ msgid "" +#~ "\n" +#~ " Filters by category" +#~ msgstr "" +#~ " Filtterit " +#~ "kategorioittain" + +#~ msgid "Test" +#~ msgstr "Testi" + +#~ msgid "Test Category" +#~ msgstr "Testi Kategoria" + +#~ msgid "Test v1" +#~ msgstr "Testi v1" + +#~ msgid "Test v2" +#~ msgstr "Testi v2" diff --git a/website_sale_product_attribute_filter_category/i18n/nl.po b/website_sale_product_attribute_filter_category/i18n/nl.po new file mode 100644 index 0000000000..bda13ad5fb --- /dev/null +++ b/website_sale_product_attribute_filter_category/i18n/nl.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_product_attribute_filter_category +# +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_product_attribute_filter_category +#: model_terms:ir.ui.view,arch_db:website_sale_product_attribute_filter_category.products_attributes_categories +msgid "" +"\n" +" Filters by category" +msgstr "" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model,name:website_sale_product_attribute_filter_category.model_product_attribute_category +msgid "Product Attribute Category" +msgstr "Product attribuut categorie" + +#. module: website_sale_product_attribute_filter_category +#: code:addons/website_sale_product_attribute_filter_category/controllers/main.py:0 +#, python-format +msgid "Undefined" +msgstr "Ongedefinieerd" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model.fields,field_description:website_sale_product_attribute_filter_category.field_product_attribute_category__website_folded +msgid "Website folded" +msgstr "Website ingevouwen" + +#~ msgid "" +#~ "\n" +#~ " Filters by category" +#~ msgstr "" +#~ "\n" +#~ " Filter op categorie" diff --git a/website_sale_product_attribute_filter_category/i18n/website_sale_product_attribute_filter_category.pot b/website_sale_product_attribute_filter_category/i18n/website_sale_product_attribute_filter_category.pot new file mode 100644 index 0000000000..9df5790f60 --- /dev/null +++ b/website_sale_product_attribute_filter_category/i18n/website_sale_product_attribute_filter_category.pot @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_product_attribute_filter_category +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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_product_attribute_filter_category +#: model_terms:ir.ui.view,arch_db:website_sale_product_attribute_filter_category.products_attributes_categories +msgid "" +"\n" +" Filters by category" +msgstr "" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model,name:website_sale_product_attribute_filter_category.model_product_attribute_category +msgid "Product Attribute Category" +msgstr "" + +#. module: website_sale_product_attribute_filter_category +#: code:addons/website_sale_product_attribute_filter_category/controllers/main.py:0 +#, python-format +msgid "Undefined" +msgstr "" + +#. module: website_sale_product_attribute_filter_category +#: model:ir.model.fields,field_description:website_sale_product_attribute_filter_category.field_product_attribute_category__website_folded +msgid "Website folded" +msgstr "" diff --git a/website_sale_product_attribute_filter_category/models/__init__.py b/website_sale_product_attribute_filter_category/models/__init__.py new file mode 100644 index 0000000000..d6c5917b92 --- /dev/null +++ b/website_sale_product_attribute_filter_category/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 product_attribute_category diff --git a/website_sale_product_attribute_filter_category/models/product_attribute_category.py b/website_sale_product_attribute_filter_category/models/product_attribute_category.py new file mode 100644 index 0000000000..c4ec62fd74 --- /dev/null +++ b/website_sale_product_attribute_filter_category/models/product_attribute_category.py @@ -0,0 +1,12 @@ +# Copyright 2020 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProductAttributeCategory(models.Model): + _inherit = "product.attribute.category" + + website_folded = fields.Boolean( + string="Website folded", + default=True, + ) diff --git a/website_sale_product_attribute_filter_category/pyproject.toml b/website_sale_product_attribute_filter_category/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/website_sale_product_attribute_filter_category/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/website_sale_product_attribute_filter_category/readme/CONFIGURE.md b/website_sale_product_attribute_filter_category/readme/CONFIGURE.md new file mode 100644 index 0000000000..6149468345 --- /dev/null +++ b/website_sale_product_attribute_filter_category/readme/CONFIGURE.md @@ -0,0 +1,9 @@ +To configure this module, you need to: + +- Go to `Website \> eCommerce \> Products \> Attribute Categories` and create + one. You can select if you want display it folded or unfolded in + website. +- Go to `Website \> eCommerce \> Products \> Attributes`, create one or more with + this category and add more than one value for each attribute. +- Go to `Website \> eCommerce \> Products \> Products` and create a product with this + attribute and assign it an attribute value. diff --git a/website_sale_product_attribute_filter_category/readme/CONTRIBUTORS.md b/website_sale_product_attribute_filter_category/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..a4200056eb --- /dev/null +++ b/website_sale_product_attribute_filter_category/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +- [Tecnativa](https://www.tecnativa.com): + + > - Sergio Teruel + > - Carlos Roca + > - Pilar Vargas + > - Carlos Lopez diff --git a/website_sale_product_attribute_filter_category/readme/DESCRIPTION.md b/website_sale_product_attribute_filter_category/readme/DESCRIPTION.md new file mode 100644 index 0000000000..02405bfa39 --- /dev/null +++ b/website_sale_product_attribute_filter_category/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module extends the functionality of website sale module to allow to +group product attributes filter by their categories. Also you can select +if you want display folded or unfolded category in website attribute's +filter. diff --git a/website_sale_product_attribute_filter_category/readme/USAGE.md b/website_sale_product_attribute_filter_category/readme/USAGE.md new file mode 100644 index 0000000000..4d2568d4e2 --- /dev/null +++ b/website_sale_product_attribute_filter_category/readme/USAGE.md @@ -0,0 +1,4 @@ +- Go to the Website Shop. +- Activate the website editor in the top right corner. +- Under the `Customize` tab, locate the `Attributes` section and enable the `Group by categories` option. +- You should now see the product attribute filters grouped by categories. diff --git a/website_sale_product_attribute_filter_category/static/description/icon.png b/website_sale_product_attribute_filter_category/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/website_sale_product_attribute_filter_category/static/description/icon.png differ diff --git a/website_sale_product_attribute_filter_category/static/description/index.html b/website_sale_product_attribute_filter_category/static/description/index.html new file mode 100644 index 0000000000..fe1bebebf1 --- /dev/null +++ b/website_sale_product_attribute_filter_category/static/description/index.html @@ -0,0 +1,462 @@ + + + + + +Website Sale Attribute Filter Category + + + +
+

Website Sale Attribute Filter Category

+ + +

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

+

This module extends the functionality of website sale module to allow to +group product attributes filter by their categories. Also you can select +if you want display folded or unfolded category in website attribute’s +filter.

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  • Go to Website \> eCommerce \> Products \> Attribute Categories and +create one. You can select if you want display it folded or unfolded +in website.
  • +
  • Go to Website \> eCommerce \> Products \> Attributes, create one +or more with this category and add more than one value for each +attribute.
  • +
  • Go to Website \> eCommerce \> Products \> Products and create a +product with this attribute and assign it an attribute value.
  • +
+
+
+

Usage

+
    +
  • Go to the Website Shop.
  • +
  • Activate the website editor in the top right corner.
  • +
  • Under the Customize tab, locate the Attributes section and +enable the Group by categories option.
  • +
  • You should now see the product attribute filters grouped by +categories.
  • +
+
+
+

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:

    +
    +
      +
    • Sergio Teruel
    • +
    • Carlos Roca
    • +
    • Pilar Vargas
    • +
    • Carlos Lopez
    • +
    +
    +
  • +
+
+
+

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_product_attribute_filter_category/static/src/scss/website_sale_attribute_filter_category.scss b/website_sale_product_attribute_filter_category/static/src/scss/website_sale_attribute_filter_category.scss new file mode 100644 index 0000000000..d9d461eb5c --- /dev/null +++ b/website_sale_product_attribute_filter_category/static/src/scss/website_sale_attribute_filter_category.scss @@ -0,0 +1,27 @@ +.website_sale_product_attribute_filter_category { + .attrib-category-radio { + margin: 0 20px; + } + + ul ul { + margin-left: 0; + margin-top: 0; + + .mt16 { + margin-top: 8px !important; + } + } + + /* Display ">" icon for collapsed elements */ + [data-bs-toggle="collapse"] .fas:before { + content: "\f105"; + } + + [aria-expanded="true"] .fas:before { + content: "\f107"; + } + + [data-bs-toggle="collapse"].collapsed .fas:before { + content: "\f105"; + } +} diff --git a/website_sale_product_attribute_filter_category/static/tests/tours/website_sale_attribute_filter_category_tour.esm.js b/website_sale_product_attribute_filter_category/static/tests/tours/website_sale_attribute_filter_category_tour.esm.js new file mode 100644 index 0000000000..64b5c69cfd --- /dev/null +++ b/website_sale_product_attribute_filter_category/static/tests/tours/website_sale_attribute_filter_category_tour.esm.js @@ -0,0 +1,29 @@ +/** @odoo-module */ + +/* Copyright 2019 Sergio Teruel + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ + +import {registry} from "@web/core/registry"; +registry + .category("web_tour.tours") + .add("website_sale_product_attribute_filter_category", { + test: true, + url: "/shop", + steps: () => [ + { + trigger: "a[href='/shop']", + }, + { + trigger: "a:contains('Customizable Desk')", + extra_trigger: ".js_attributes:has(span:contains('Test category'))", + }, + { + trigger: "a[href='/shop']", + }, + // Span element must be available directly + { + trigger: "a:contains('Customizable Desk')", + extra_trigger: "span:contains('Test category')", + }, + ], + }); diff --git a/website_sale_product_attribute_filter_category/tests/__init__.py b/website_sale_product_attribute_filter_category/tests/__init__.py new file mode 100644 index 0000000000..5744efa2ec --- /dev/null +++ b/website_sale_product_attribute_filter_category/tests/__init__.py @@ -0,0 +1 @@ +from . import test_website_sale_product_attribute_filter_category diff --git a/website_sale_product_attribute_filter_category/tests/test_website_sale_product_attribute_filter_category.py b/website_sale_product_attribute_filter_category/tests/test_website_sale_product_attribute_filter_category.py new file mode 100644 index 0000000000..7e6d2a7cf4 --- /dev/null +++ b/website_sale_product_attribute_filter_category/tests/test_website_sale_product_attribute_filter_category.py @@ -0,0 +1,70 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import Command +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 WebsiteSaleAttributeFilterCategoryHttpCase(HttpCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + # Models + AttributeCategory = cls.env["product.attribute.category"] + ProductAttribute = cls.env["product.attribute"] + ProductAttributeValue = cls.env["product.attribute.value"] + ProductAttributeLine = cls.env["product.template.attribute.line"] + cls.attribute_category = AttributeCategory.create( + {"name": "Test category", "website_folded": False} + ) + cls.product_attribute = ProductAttribute.create( + { + "name": "Test", + "create_variant": "no_variant", + "category_id": cls.attribute_category.id, + } + ) + cls.product_attribute_value_test_1 = ProductAttributeValue.create( + {"name": "Test v1", "attribute_id": cls.product_attribute.id} + ) + cls.product_attribute_value_test_2 = ProductAttributeValue.create( + {"name": "Test v2", "attribute_id": cls.product_attribute.id} + ) + cls.product_template = cls.env.ref("product.product_product_4_product_template") + cls.product_attribute_line = ProductAttributeLine.create( + { + "product_tmpl_id": cls.product_template.id, + "attribute_id": cls.product_attribute.id, + "value_ids": [ + Command.set( + [ + cls.product_attribute_value_test_1.id, + cls.product_attribute_value_test_2.id, + ], + ) + ], + } + ) + cls.product_template.write( + { + "attribute_line_ids": [(4, cls.product_attribute_line.id)], + "is_published": True, + } + ) + # Active filter in /shop. + cls.env.ref("website_sale.products_attributes").active = True + cls.env.ref( + "website_sale_product_attribute_filter_category.products_attributes_categories" + ).active = True + + def test_ui_website(self): + """Test frontend tour.""" + self.start_tour( + "/shop", + "website_sale_product_attribute_filter_category", + login="admin", + ) diff --git a/website_sale_product_attribute_filter_category/views/snippets/snippets.xml b/website_sale_product_attribute_filter_category/views/snippets/snippets.xml new file mode 100644 index 0000000000..502870f472 --- /dev/null +++ b/website_sale_product_attribute_filter_category/views/snippets/snippets.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/website_sale_product_attribute_filter_category/views/templates.xml b/website_sale_product_attribute_filter_category/views/templates.xml new file mode 100644 index 0000000000..17e5eab09f --- /dev/null +++ b/website_sale_product_attribute_filter_category/views/templates.xml @@ -0,0 +1,66 @@ + + + + + diff --git a/website_sale_product_attribute_filter_category/views/website_sale_product_attribute_filter_category_view.xml b/website_sale_product_attribute_filter_category/views/website_sale_product_attribute_filter_category_view.xml new file mode 100644 index 0000000000..e78d52c991 --- /dev/null +++ b/website_sale_product_attribute_filter_category/views/website_sale_product_attribute_filter_category_view.xml @@ -0,0 +1,16 @@ + + + + product.attribute.category + + + + + + + + +