Skip to content

Commit

Permalink
[ADD] website_sale_product_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
chienandalu committed Jan 23, 2025
1 parent cf1fb2d commit 6aa5aab
Show file tree
Hide file tree
Showing 14 changed files with 786 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/website_sale_product_matrix/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
104 changes: 104 additions & 0 deletions website_sale_product_matrix/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/e-commerce/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 <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_product_matrix%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-chienandalu|

This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/15.0/website_sale_product_matrix>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions website_sale_product_matrix/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import controllers
19 changes: 19 additions & 0 deletions website_sale_product_matrix/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": {},
}
1 change: 1 addition & 0 deletions website_sale_product_matrix/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
45 changes: 45 additions & 0 deletions website_sale_product_matrix/controllers/main.py
Original file line number Diff line number Diff line change
@@ -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")
5 changes: 5 additions & 0 deletions website_sale_product_matrix/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -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**.
2 changes: 2 additions & 0 deletions website_sale_product_matrix/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Tecnativa (https://www.tecnativa.com)
* David Vidal
2 changes: 2 additions & 0 deletions website_sale_product_matrix/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions website_sale_product_matrix/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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.
Loading

0 comments on commit 6aa5aab

Please sign in to comment.