diff --git a/setup/website_sale_product_matrix/odoo/addons/website_sale_product_matrix b/setup/website_sale_product_matrix/odoo/addons/website_sale_product_matrix new file mode 120000 index 0000000000..8d94a91199 --- /dev/null +++ b/setup/website_sale_product_matrix/odoo/addons/website_sale_product_matrix @@ -0,0 +1 @@ +../../../../website_sale_product_matrix \ No newline at end of file diff --git a/setup/website_sale_product_matrix/setup.py b/setup/website_sale_product_matrix/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/website_sale_product_matrix/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_sale_product_matrix/README.rst b/website_sale_product_matrix/README.rst new file mode 100644 index 0000000000..649d5b668a --- /dev/null +++ b/website_sale_product_matrix/README.rst @@ -0,0 +1,104 @@ +=========================== +Product matrix in eCommerce +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8f1baf6f3c247066848c48779a1a1441552dbb72dceefd3c7143c851d0fb04d5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/15.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-15-0/e-commerce-15-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=15.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. + +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 + +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-chienandalu| image:: https://github.com/chienandalu.png?size=40px + :target: https://github.com/chienandalu + :alt: chienandalu + +Current `maintainer `__: + +|maintainer-chienandalu| + +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..b23f6b5a04 --- /dev/null +++ b/website_sale_product_matrix/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Product matrix in eCommerce", + "version": "15.0.1.0.0", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/e-commerce", + "category": "Website", + "maintainers": ["chienandalu"], + "depends": [ + "sale_product_matrix", + "website_sale", + ], + "data": [ + "templates/product_template.xml", + ], + "assets": {}, +} 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..b97f83a394 --- /dev/null +++ b/website_sale_product_matrix/controllers/main.py @@ -0,0 +1,45 @@ +# 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, *arg, **args): + """This route is called when adding a product to cart from the product matrix""" + # import wdb; wdb.set_trace() + sale_order = request.website.sale_get_order(force_create=True) + if sale_order.state != "draft": + request.session["sale_order_id"] = None + sale_order = request.website.sale_get_order(force_create=True) + + product_custom_attribute_values = None + if kw.get("product_custom_attribute_values"): + product_custom_attribute_values = json_scriptsafe.loads( + kw.get("product_custom_attribute_values") + ) + + no_variant_attribute_values = None + if kw.get("no_variant_attribute_values"): + no_variant_attribute_values = json_scriptsafe.loads( + kw.get("no_variant_attribute_values") + ) + + sale_order._cart_update( + product_id=int(product_id), + add_qty=add_qty, + set_qty=set_qty, + product_custom_attribute_values=product_custom_attribute_values, + no_variant_attribute_values=no_variant_attribute_values, + ) + if kw.get("express"): + return request.redirect("/shop/checkout?express=1") + return request.redirect("/shop/cart") 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..9967361ba9 --- /dev/null +++ b/website_sale_product_matrix/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +* Tecnativa (https://www.tecnativa.com) + * David Vidal diff --git a/website_sale_product_matrix/readme/DESCRIPTION.md b/website_sale_product_matrix/readme/DESCRIPTION.md new file mode 100644 index 0000000000..37e4438bd6 --- /dev/null +++ b/website_sale_product_matrix/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +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/USAGE.md b/website_sale_product_matrix/readme/USAGE.md new file mode 100644 index 0000000000..7bb6ed8427 --- /dev/null +++ b/website_sale_product_matrix/readme/USAGE.md @@ -0,0 +1,4 @@ +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/index.html b/website_sale_product_matrix/static/description/index.html new file mode 100644 index 0000000000..c3c8f5773e --- /dev/null +++ b/website_sale_product_matrix/static/description/index.html @@ -0,0 +1,448 @@ + + + + + +Product matrix in eCommerce + + + +
+

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. +
+
+
+

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:

+

chienandalu

+

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/product_configurator_mixin.esm.js b/website_sale_product_matrix/static/src/js/product_configurator_mixin.esm.js new file mode 100644 index 0000000000..63cd26a617 --- /dev/null +++ b/website_sale_product_matrix/static/src/js/product_configurator_mixin.esm.js @@ -0,0 +1,20 @@ +/** @odoo-module **/ +import publicWidget from "web.public.widget"; +import wUtils from "website.utils"; + +// If next dependency is not declared publicWidget.registry.WebsiteSale will be +// undefined +import "website_sale.website_sale"; + +// TODO: Add logic to improve UX +publicWidget.registry.WebsiteSale.include({ + events: Object.assign({}, publicWidget.registry.WebsiteSale.events, { + "click .o_we_order_matrix": "addToCartFromMatrix", + }), + /** + * Used to add product depending on stayOnPageOption value. + */ + addToCartFromMatrix(params) { + return wUtils.sendRequest("/shop/cart/update_from_matrix", params); + }, +}); 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..0025b9030e --- /dev/null +++ b/website_sale_product_matrix/templates/product_template.xml @@ -0,0 +1,128 @@ + + + + +