From f231c0429fa7f435e5c996a073a8074606da3709 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 6 Mar 2025 17:12:04 +0100 Subject: [PATCH] [ADD] website_sale_secondary_unit_product_matrix: New module TT52533 --- ...website_sale_secondary_unit_product_matrix | 1 + .../setup.py | 6 + .../README.rst | 104 ++++ .../__init__.py | 0 .../__manifest__.py | 23 + .../readme/CONFIGURE.md | 5 + .../readme/CONTRIBUTORS.md | 2 + .../readme/DESCRIPTION.md | 2 + .../readme/USAGE.md | 5 + .../static/description/index.html | 448 ++++++++++++++++++ .../static/src/js/website_sale.esm.js | 30 ++ .../templates/product_template.xml | 46 ++ 12 files changed, 672 insertions(+) create mode 120000 setup/website_sale_secondary_unit_product_matrix/odoo/addons/website_sale_secondary_unit_product_matrix create mode 100644 setup/website_sale_secondary_unit_product_matrix/setup.py create mode 100644 website_sale_secondary_unit_product_matrix/README.rst create mode 100644 website_sale_secondary_unit_product_matrix/__init__.py create mode 100644 website_sale_secondary_unit_product_matrix/__manifest__.py create mode 100644 website_sale_secondary_unit_product_matrix/readme/CONFIGURE.md create mode 100644 website_sale_secondary_unit_product_matrix/readme/CONTRIBUTORS.md create mode 100644 website_sale_secondary_unit_product_matrix/readme/DESCRIPTION.md create mode 100644 website_sale_secondary_unit_product_matrix/readme/USAGE.md create mode 100644 website_sale_secondary_unit_product_matrix/static/description/index.html create mode 100644 website_sale_secondary_unit_product_matrix/static/src/js/website_sale.esm.js create mode 100644 website_sale_secondary_unit_product_matrix/templates/product_template.xml diff --git a/setup/website_sale_secondary_unit_product_matrix/odoo/addons/website_sale_secondary_unit_product_matrix b/setup/website_sale_secondary_unit_product_matrix/odoo/addons/website_sale_secondary_unit_product_matrix new file mode 120000 index 0000000000..1a31c91d97 --- /dev/null +++ b/setup/website_sale_secondary_unit_product_matrix/odoo/addons/website_sale_secondary_unit_product_matrix @@ -0,0 +1 @@ +../../../../website_sale_secondary_unit_product_matrix \ No newline at end of file diff --git a/setup/website_sale_secondary_unit_product_matrix/setup.py b/setup/website_sale_secondary_unit_product_matrix/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/website_sale_secondary_unit_product_matrix/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_sale_secondary_unit_product_matrix/README.rst b/website_sale_secondary_unit_product_matrix/README.rst new file mode 100644 index 0000000000..540ca8b3c1 --- /dev/null +++ b/website_sale_secondary_unit_product_matrix/README.rst @@ -0,0 +1,104 @@ +================================================ +Product matrix with secondary units 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_secondary_unit_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_secondary_unit_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_secondary_unit_product_matrix/__init__.py b/website_sale_secondary_unit_product_matrix/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/website_sale_secondary_unit_product_matrix/__manifest__.py b/website_sale_secondary_unit_product_matrix/__manifest__.py new file mode 100644 index 0000000000..c789745349 --- /dev/null +++ b/website_sale_secondary_unit_product_matrix/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2024 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Product matrix with secondary units 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": [ + "website_sale_product_matrix", + "sale_product_matrix_secondary_unit", + ], + "data": [ + "templates/product_template.xml", + ], + "assets": { + "web.assets_frontend": [ + "website_sale_secondary_unit_product_matrix/static/src/js/**/*.js", + ], + }, +} diff --git a/website_sale_secondary_unit_product_matrix/readme/CONFIGURE.md b/website_sale_secondary_unit_product_matrix/readme/CONFIGURE.md new file mode 100644 index 0000000000..220cdba07e --- /dev/null +++ b/website_sale_secondary_unit_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_secondary_unit_product_matrix/readme/CONTRIBUTORS.md b/website_sale_secondary_unit_product_matrix/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..9967361ba9 --- /dev/null +++ b/website_sale_secondary_unit_product_matrix/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +* Tecnativa (https://www.tecnativa.com) + * David Vidal diff --git a/website_sale_secondary_unit_product_matrix/readme/DESCRIPTION.md b/website_sale_secondary_unit_product_matrix/readme/DESCRIPTION.md new file mode 100644 index 0000000000..37e4438bd6 --- /dev/null +++ b/website_sale_secondary_unit_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_secondary_unit_product_matrix/readme/USAGE.md b/website_sale_secondary_unit_product_matrix/readme/USAGE.md new file mode 100644 index 0000000000..aa24f5f64e --- /dev/null +++ b/website_sale_secondary_unit_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_secondary_unit_product_matrix/static/description/index.html b/website_sale_secondary_unit_product_matrix/static/description/index.html new file mode 100644 index 0000000000..a2d2e7453b --- /dev/null +++ b/website_sale_secondary_unit_product_matrix/static/description/index.html @@ -0,0 +1,448 @@ + + + + + +Product matrix with secondary units in eCommerce + + + +
+

Product matrix with secondary units 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_secondary_unit_product_matrix/static/src/js/website_sale.esm.js b/website_sale_secondary_unit_product_matrix/static/src/js/website_sale.esm.js new file mode 100644 index 0000000000..92f4326039 --- /dev/null +++ b/website_sale_secondary_unit_product_matrix/static/src/js/website_sale.esm.js @@ -0,0 +1,30 @@ +/** @odoo-module **/ +import publicWidget from "web.public.widget"; + +// 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({ + /** + * @override + */ + _parseGridChanges(product_template_id, $form) { + const grid = this._super.apply(this, arguments); + const secondary_unit_select = $form.getElementsByClassName( + "o_matrix_secondary_unit" + ); + if (!secondary_unit_select.length) { + return grid; + } + // Reduce to get the selected option value + const selected_secondary_unit = Array.from(secondary_unit_select).reduce( + (_, select) => select.value, + null + ); + grid.secondary_unit = + (selected_secondary_unit && parseInt(selected_secondary_unit)) || false; + return grid; + }, +}); diff --git a/website_sale_secondary_unit_product_matrix/templates/product_template.xml b/website_sale_secondary_unit_product_matrix/templates/product_template.xml new file mode 100644 index 0000000000..effee14e20 --- /dev/null +++ b/website_sale_secondary_unit_product_matrix/templates/product_template.xml @@ -0,0 +1,46 @@ + + + +