diff --git a/website_sale_product_matrix/README.rst b/website_sale_product_matrix/README.rst new file mode 100644 index 0000000000..44e989ca73 --- /dev/null +++ b/website_sale_product_matrix/README.rst @@ -0,0 +1,119 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=========================== +Product matrix in eCommerce +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:f0e3a558de6978e0fd8c88287d529d3302741a03d01ce448ce5b2e49a2c12ae0 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_product_matrix + :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_product_matrix + :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| + +With this module we'll be able to use the product matrix in the +eCommerce so our customers can easily add products to their carts. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +- Go to a product with variants or create one. +- In the *Attributes and variants* tab, *Sales Variant Selection* + section, select **Order grid entry**. + +Usage +===== + +To use this module, you need to: + +1. Go to the configured product web page. +2. You'll se the matrix where you can add units to the cart. + +Known issues / Roadmap +====================== + +This module doesn't have any effect on the wishlist: adding a +matrix-configured product from the wishlist page falls back to the +regular product configurator instead of opening the matrix. A glue +module such as ``website_sale_wishlist_product_matrix`` would be needed +to fix this. + +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 (https://www.tecnativa.com) + + - David Vidal + - Pilar Vargas + - Cristina Hidalgo + +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-pilarvargas-tecnativa| image:: https://github.com/pilarvargas-tecnativa.png?size=40px + :target: https://github.com/pilarvargas-tecnativa + :alt: pilarvargas-tecnativa + +Current `maintainer `__: + +|maintainer-pilarvargas-tecnativa| + +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_matrix/__init__.py b/website_sale_product_matrix/__init__.py new file mode 100644 index 0000000000..e046e49fbe --- /dev/null +++ b/website_sale_product_matrix/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/website_sale_product_matrix/__manifest__.py b/website_sale_product_matrix/__manifest__.py new file mode 100644 index 0000000000..21ec699f62 --- /dev/null +++ b/website_sale_product_matrix/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2024 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Product matrix in eCommerce", + "version": "19.0.1.0.0", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/e-commerce", + "category": "Website", + "maintainers": ["pilarvargas-tecnativa"], + "depends": [ + "sale_product_matrix", + "website_sale", + ], + "data": [ + "templates/product_template.xml", + ], + "assets": { + "web.assets_frontend": [ + "website_sale_product_matrix/static/src/js/**/*.js", + "website_sale_product_matrix/static/src/scss/**/*.scss", + ], + }, +} diff --git a/website_sale_product_matrix/controllers/__init__.py b/website_sale_product_matrix/controllers/__init__.py new file mode 100644 index 0000000000..12a7e529b6 --- /dev/null +++ b/website_sale_product_matrix/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/website_sale_product_matrix/controllers/main.py b/website_sale_product_matrix/controllers/main.py new file mode 100644 index 0000000000..b134d478cf --- /dev/null +++ b/website_sale_product_matrix/controllers/main.py @@ -0,0 +1,27 @@ +# Copyright 2025 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.http import request, route + +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteSaleProductMatrix(WebsiteSale): + @route( + ["/shop/cart/update_from_matrix"], + type="http", + auth="public", + methods=["POST"], + website=True, + ) + def cart_update_from_matrix(self, product_template_id, grid, **kw): + """This route is called when adding a product to cart from the product matrix""" + sale_order = request.cart or request.website._create_cart() + sale_order.update( + { + "grid_product_tmpl_id": int(product_template_id), + "grid_update": True, + "grid": grid, + } + ) + sale_order._apply_grid() + return request.redirect("/shop/cart") diff --git a/website_sale_product_matrix/i18n/ca.po b/website_sale_product_matrix/i18n/ca.po new file mode 100644 index 0000000000..305ac155df --- /dev/null +++ b/website_sale_product_matrix/i18n/ca.po @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_product_matrix +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-05-05 15:14+0000\n" +"Last-Translator: Anonymous \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 5.15.2\n" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid " Configure options" +msgstr " Afegir a la cistella" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "UPDATE CART WITH OPTIONS" +msgstr "ACTUALITZAR CISTELLA AMB OPCIONS" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "×" +msgstr "×" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Add one" +msgstr "Afegir-ne un" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "Close" +msgstr "Tancar" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "Configure product options" +msgstr "Configurar opcions de producte" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Not available" +msgstr "No disponible" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Remove one" +msgstr "Eliminar-ne un" diff --git a/website_sale_product_matrix/i18n/es.po b/website_sale_product_matrix/i18n/es.po new file mode 100644 index 0000000000..32b38abff0 --- /dev/null +++ b/website_sale_product_matrix/i18n/es.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_product_matrix +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-07-10 06:26+0000\n" +"PO-Revision-Date: 2026-05-05 15:14+0000\n" +"Last-Translator: Anonymous \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 5.15.2\n" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid " Configure options" +msgstr " Añadir al carro" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "UPDATE CART WITH OPTIONS" +msgstr "ACTUALIZAR CARRO CON OPCIONES" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "×" +msgstr "×" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Add one" +msgstr "Añadir uno" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "Close" +msgstr "Cerrar" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "Configure product options" +msgstr "Añadir opciones de producto" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Not available" +msgstr "No disponible" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Remove one" +msgstr "Eliminar uno" diff --git a/website_sale_product_matrix/i18n/it.po b/website_sale_product_matrix/i18n/it.po new file mode 100644 index 0000000000..cd6912c63c --- /dev/null +++ b/website_sale_product_matrix/i18n/it.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_product_matrix +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-05-05 15:14+0000\n" +"Last-Translator: mymage \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" +"X-Generator: Weblate 5.15.2\n" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid " Configure options" +msgstr " Opzioni configurazione" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "UPDATE CART WITH OPTIONS" +msgstr "AGGIORNA CARRELLO CON OPZIONI" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Add one" +msgstr "Aggiungi uno" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "Close" +msgstr "Chiudi" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "Configure product options" +msgstr "Configura opzioni prodotto" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Not available" +msgstr "Non disponibile" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Remove one" +msgstr "Rimuovi uno" diff --git a/website_sale_product_matrix/i18n/website_sale_product_matrix.pot b/website_sale_product_matrix/i18n/website_sale_product_matrix.pot new file mode 100644 index 0000000000..0181402d31 --- /dev/null +++ b/website_sale_product_matrix/i18n/website_sale_product_matrix.pot @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_product_matrix +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 19.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_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.cta_wrapper +msgid " Configure options" +msgstr "" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "UPDATE CART WITH OPTIONS" +msgstr "" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Add one" +msgstr "" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "Close" +msgstr "" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product +msgid "Configure product options" +msgstr "" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Not available" +msgstr "" + +#. module: website_sale_product_matrix +#: model_terms:ir.ui.view,arch_db:website_sale_product_matrix.product_matrix +msgid "Remove one" +msgstr "" diff --git a/website_sale_product_matrix/pyproject.toml b/website_sale_product_matrix/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/website_sale_product_matrix/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/website_sale_product_matrix/readme/CONFIGURE.md b/website_sale_product_matrix/readme/CONFIGURE.md new file mode 100644 index 0000000000..220cdba07e --- /dev/null +++ b/website_sale_product_matrix/readme/CONFIGURE.md @@ -0,0 +1,5 @@ +To configure this module, you need to: + +- Go to a product with variants or create one. +- In the *Attributes and variants* tab, *Sales Variant Selection* section, select + **Order grid entry**. diff --git a/website_sale_product_matrix/readme/CONTRIBUTORS.md b/website_sale_product_matrix/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..a7af567278 --- /dev/null +++ b/website_sale_product_matrix/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +* Tecnativa (https://www.tecnativa.com) + * David Vidal + * Pilar Vargas + * Cristina Hidalgo diff --git a/website_sale_product_matrix/readme/DESCRIPTION.md b/website_sale_product_matrix/readme/DESCRIPTION.md new file mode 100644 index 0000000000..e99af76b2f --- /dev/null +++ b/website_sale_product_matrix/readme/DESCRIPTION.md @@ -0,0 +1 @@ +With this module we'll be able to use the product matrix in the eCommerce so our customers can easily add products to their carts. diff --git a/website_sale_product_matrix/readme/ROADMAP.md b/website_sale_product_matrix/readme/ROADMAP.md new file mode 100644 index 0000000000..6bf90823b6 --- /dev/null +++ b/website_sale_product_matrix/readme/ROADMAP.md @@ -0,0 +1,4 @@ +This module doesn't have any effect on the wishlist: adding a matrix-configured +product from the wishlist page falls back to the regular product configurator +instead of opening the matrix. A glue module such as +`website_sale_wishlist_product_matrix` would be needed to fix this. diff --git a/website_sale_product_matrix/readme/USAGE.md b/website_sale_product_matrix/readme/USAGE.md new file mode 100644 index 0000000000..aa24f5f64e --- /dev/null +++ b/website_sale_product_matrix/readme/USAGE.md @@ -0,0 +1,5 @@ +To use this module, you need to: + +1. Go to the configured product web page. +2. You'll se the matrix where you can add units to the cart. + diff --git a/website_sale_product_matrix/static/description/icon.png b/website_sale_product_matrix/static/description/icon.png new file mode 100644 index 0000000000..1dcc49c24f Binary files /dev/null and b/website_sale_product_matrix/static/description/icon.png differ diff --git a/website_sale_product_matrix/static/description/index.html b/website_sale_product_matrix/static/description/index.html new file mode 100644 index 0000000000..d153f5dcf4 --- /dev/null +++ b/website_sale_product_matrix/static/description/index.html @@ -0,0 +1,465 @@ + + + + + +Product matrix in eCommerce + + + +
+ + + +Odoo Community Association + +
+

Product matrix in eCommerce

+ +

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

+

With this module we’ll be able to use the product matrix in the +eCommerce so our customers can easily add products to their carts.

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  • Go to a product with variants or create one.
  • +
  • In the Attributes and variants tab, Sales Variant Selection +section, select Order grid entry.
  • +
+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to the configured product web page.
  2. +
  3. You’ll se the matrix where you can add units to the cart.
  4. +
+
+
+

Known issues / Roadmap

+

This module doesn’t have any effect on the wishlist: adding a +matrix-configured product from the wishlist page falls back to the +regular product configurator instead of opening the matrix. A glue +module such as website_sale_wishlist_product_matrix would be needed +to fix this.

+
+
+

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.

+

Current maintainer:

+

pilarvargas-tecnativa

+

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_matrix/static/src/js/website_sale.esm.js b/website_sale_product_matrix/static/src/js/website_sale.esm.js new file mode 100644 index 0000000000..054ee3bd77 --- /dev/null +++ b/website_sale_product_matrix/static/src/js/website_sale.esm.js @@ -0,0 +1,42 @@ +import publicWidget from "@web/legacy/js/public/public_widget"; +import wUtils from "@website/js/utils"; + +publicWidget.registry.WebsiteSaleProductMatrix = publicWidget.Widget.extend({ + selector: "#product_detail", + events: { + "click .o_we_order_matrix": "addToCartFromMatrix", + }, + /** + * Overridable method to add stuff to the grid + * @param {Number} product_template_id + * @param {HTMLFormElement} $form + * @returns {Object} + */ + _parseGridChanges(product_template_id, $form) { + const inputs = $form.getElementsByClassName("o_matrix_input"); + const changes = Array.from(inputs).map((input) => { + return { + qty: parseInt(input.value, 10) || 0, + ptav_ids: JSON.parse(input.dataset.ptav_ids), + }; + }); + return { + product_template_id: product_template_id, + changes: changes, + }; + }, + /** + * Parse the grid with the changes to apply into the order + * @param {Event} ev + * @returns {Promise} + */ + addToCartFromMatrix(ev) { + const $form = ev.currentTarget.closest("form"); + const params = { + product_template_id: parseInt($form.dataset.product_template_id, 10), + }; + const grid = this._parseGridChanges(params.product_template_id, $form); + params.grid = JSON.stringify(grid); + return wUtils.sendRequest("/shop/cart/update_from_matrix", params); + }, +}); diff --git a/website_sale_product_matrix/static/src/scss/matrix_style.scss b/website_sale_product_matrix/static/src/scss/matrix_style.scss new file mode 100644 index 0000000000..4c46aceefb --- /dev/null +++ b/website_sale_product_matrix/static/src/scss/matrix_style.scss @@ -0,0 +1,15 @@ +.o_matrix_input { + // The same as in max-width for css_quantity input group + min-width: 50px; +} +#product_matrix_form { + // Allow inner contents scrolling + display: contents; +} +#modalMatrix { + // Override defaults to avoid scrolling in large option sets + .modal-dialog { + max-width: none; + width: 99%; + } +} diff --git a/website_sale_product_matrix/templates/product_template.xml b/website_sale_product_matrix/templates/product_template.xml new file mode 100644 index 0000000000..e6caac9335 --- /dev/null +++ b/website_sale_product_matrix/templates/product_template.xml @@ -0,0 +1,206 @@ + + + + + + +