diff --git a/pos_order_exclude_attribute_combination/README.rst b/pos_order_exclude_attribute_combination/README.rst new file mode 100644 index 0000000000..3ad0880636 --- /dev/null +++ b/pos_order_exclude_attribute_combination/README.rst @@ -0,0 +1,97 @@ +================================================================= +POS Orders - Limit seletion of not allowed attribute combinations +================================================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/16.0/pos_order_exclude_attribute_combination + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_order_exclude_attribute_combination + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/pos&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allow user to show warning for Limit seletion of not allowed attribute combinations + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Configure the product with variant exclude option +#. Open the POS Session add select product +#. When you select attribute then check for combination available if not then show warning on top of the dialog + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* Sandip Vyas + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* Open Source Integrators + +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-ursais| image:: https://github.com/ursais.png?size=40px + :target: https://github.com/ursais + :alt: ursais + +Current `maintainer `__: + +|maintainer-ursais| + +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_order_exclude_attribute_combination/__init__.py b/pos_order_exclude_attribute_combination/__init__.py new file mode 100644 index 0000000000..ecd4f0837c --- /dev/null +++ b/pos_order_exclude_attribute_combination/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2022 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/pos_order_exclude_attribute_combination/__manifest__.py b/pos_order_exclude_attribute_combination/__manifest__.py new file mode 100644 index 0000000000..7f9f25a882 --- /dev/null +++ b/pos_order_exclude_attribute_combination/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright (C) 2022 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "POS Orders - Limit seletion of not allowed attribute combinations", + "version": "16.0.1.0.0", + "summary": """Product attribute values allow to set Exclude for + to make some combinations unavailable.""", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Point of Sale", + "maintainer": "Open Source Integrators", + "website": "https://github.com/OCA/pos", + "depends": ["point_of_sale"], + "maintainers": ["ursais"], + "installable": True, + "assets": { + "point_of_sale.assets": [ + "pos_order_exclude_attribute_combination/static/src/js/**/*.js", + "pos_order_exclude_attribute_combination/static/src/xml/**/*.xml", + "pos_order_exclude_attribute_combination/static/src/scss/**/*.scss", + ], + }, +} diff --git a/pos_order_exclude_attribute_combination/models/__init__.py b/pos_order_exclude_attribute_combination/models/__init__.py new file mode 100644 index 0000000000..e8e3bb2c12 --- /dev/null +++ b/pos_order_exclude_attribute_combination/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2022 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import product diff --git a/pos_order_exclude_attribute_combination/models/product.py b/pos_order_exclude_attribute_combination/models/product.py new file mode 100644 index 0000000000..28ab9161d3 --- /dev/null +++ b/pos_order_exclude_attribute_combination/models/product.py @@ -0,0 +1,22 @@ +# Copyright (C) 2022 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + def get_product_attribute_value(self, attribute_values): + return self.env["product.template.attribute.value"].search( + [ + ("product_attribute_value_id", "in", attribute_values), + ("product_tmpl_id", "=", self.id), + ] + ) + + def get_product_info(self, product_id, combination): + combination = self.get_product_attribute_value(combination) + return self._is_combination_possible( + combination=combination, parent_combination=combination + ) diff --git a/pos_order_exclude_attribute_combination/readme/CONTRIBUTORS.rst b/pos_order_exclude_attribute_combination/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..b7be22b0cc --- /dev/null +++ b/pos_order_exclude_attribute_combination/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sandip Vyas diff --git a/pos_order_exclude_attribute_combination/readme/CREDITS.rst b/pos_order_exclude_attribute_combination/readme/CREDITS.rst new file mode 100644 index 0000000000..0eff0acf4e --- /dev/null +++ b/pos_order_exclude_attribute_combination/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Open Source Integrators diff --git a/pos_order_exclude_attribute_combination/readme/DESCRIPTION.rst b/pos_order_exclude_attribute_combination/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..e5772e0734 --- /dev/null +++ b/pos_order_exclude_attribute_combination/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allow user to show warning for Limit seletion of not allowed attribute combinations diff --git a/pos_order_exclude_attribute_combination/readme/USAGE.rst b/pos_order_exclude_attribute_combination/readme/USAGE.rst new file mode 100644 index 0000000000..5fa3a29ab8 --- /dev/null +++ b/pos_order_exclude_attribute_combination/readme/USAGE.rst @@ -0,0 +1,5 @@ +To use this module, you need to: + +#. Configure the product with variant exclude option +#. Open the POS Session add select product +#. When you select attribute then check for combination available if not then show warning on top of the dialog diff --git a/pos_order_exclude_attribute_combination/static/description/icon.png b/pos_order_exclude_attribute_combination/static/description/icon.png new file mode 100644 index 0000000000..85d01763f3 Binary files /dev/null and b/pos_order_exclude_attribute_combination/static/description/icon.png differ diff --git a/pos_order_exclude_attribute_combination/static/description/index.html b/pos_order_exclude_attribute_combination/static/description/index.html new file mode 100644 index 0000000000..6c44fb2943 --- /dev/null +++ b/pos_order_exclude_attribute_combination/static/description/index.html @@ -0,0 +1,439 @@ + + + + + + +POS Orders - Limit seletion of not allowed attribute combinations + + + +
+

POS Orders - Limit seletion of not allowed attribute combinations

+ + +

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

+

This module allow user to show warning for Limit seletion of not allowed attribute combinations

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Configure the product with variant exclude option
  2. +
  3. Open the POS Session add select product
  4. +
  5. When you select attribute then check for combination available if not then show warning on top of the dialog
  6. +
+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Open Source Integrators
  • +
+
+ +
+

Other credits

+

The development of this module has been financially supported by:

+ +
+
+

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:

+

ursais

+

This module is part of the OCA/pos project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/pos_order_exclude_attribute_combination/static/src/js/ProductConfiguratorPopup.js b/pos_order_exclude_attribute_combination/static/src/js/ProductConfiguratorPopup.js new file mode 100644 index 0000000000..9e49b1d037 --- /dev/null +++ b/pos_order_exclude_attribute_combination/static/src/js/ProductConfiguratorPopup.js @@ -0,0 +1,60 @@ +odoo.define( + "pos_order_exclude_attribute_combination.ProductConfiguratorPopup", + function (require) { + "use strict"; + + const ProductConfiguratorPopup = + require("point_of_sale.ProductConfiguratorPopup").ProductConfiguratorPopup; + const Registries = require("point_of_sale.Registries"); + const {onMounted, useState} = owl; + + const ProductConfiguratorPopupCombination = (ProductConfiguratorPopup) => + class extends ProductConfiguratorPopup { + setup() { + super.setup(); + this.state = useState({ + is_combination_possible: true, + }); + onMounted(() => { + this.getProductCombinationInfo(); + $(this.el) + .find('input[type="radio"]') + .on("change", () => this.getProductCombinationInfo(this)); + $(this.el) + .find("select") + .on("change", () => this.getProductCombinationInfo(this)); + }); + } + async getProductCombinationInfo() { + var selected_attributes = []; + this.env.attribute_components.forEach((attribute_component) => { + const {selected_value} = attribute_component.state; + selected_attributes.push(parseFloat(selected_value)); + }); + await this.loadProductCombinationInfo( + this.props.product, + selected_attributes + ); + } + async loadProductCombinationInfo(product, selected_attributes) { + const isCombinationPossible = await this.rpc({ + model: "product.template", + method: "get_product_info", + args: [ + [product.product_tmpl_id], + product.id, + selected_attributes, + ], + }); + this.state.is_combination_possible = isCombinationPossible; + } + }; + + Registries.Component.extend( + ProductConfiguratorPopup, + ProductConfiguratorPopupCombination + ); + + return ProductConfiguratorPopup; + } +); diff --git a/pos_order_exclude_attribute_combination/static/src/scss/ProductConfiguratorPopup.scss b/pos_order_exclude_attribute_combination/static/src/scss/ProductConfiguratorPopup.scss new file mode 100644 index 0000000000..88b384d354 --- /dev/null +++ b/pos_order_exclude_attribute_combination/static/src/scss/ProductConfiguratorPopup.scss @@ -0,0 +1,22 @@ +.no_combination { + color: #997404; + background-color: #fff3cd; + border-color: #ffecb5; + display: block; + position: relative; + padding: 1rem 1rem; + margin-bottom: 1rem; + border: 1px solid transparent; + border-radius: 0.25rem; +} +.tzo_confirm { + display: flex !important; + align-items: center; + justify-content: center; + background: $primary !important; + border-color: $primary !important; + color: white !important; + &:disabled { + background-color: rgba($primary, 0.7) !important; + } +} diff --git a/pos_order_exclude_attribute_combination/static/src/xml/ProductConfiguratorPopup.xml b/pos_order_exclude_attribute_combination/static/src/xml/ProductConfiguratorPopup.xml new file mode 100644 index 0000000000..35806d49f8 --- /dev/null +++ b/pos_order_exclude_attribute_combination/static/src/xml/ProductConfiguratorPopup.xml @@ -0,0 +1,25 @@ + + + + + + + +
This combination does not exist.
+
+ + state.is_combination_possible + +
+
diff --git a/setup/pos_order_exclude_attribute_combination/odoo/addons/pos_order_exclude_attribute_combination b/setup/pos_order_exclude_attribute_combination/odoo/addons/pos_order_exclude_attribute_combination new file mode 120000 index 0000000000..07a4e25060 --- /dev/null +++ b/setup/pos_order_exclude_attribute_combination/odoo/addons/pos_order_exclude_attribute_combination @@ -0,0 +1 @@ +../../../../pos_order_exclude_attribute_combination \ No newline at end of file diff --git a/setup/pos_order_exclude_attribute_combination/setup.py b/setup/pos_order_exclude_attribute_combination/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/pos_order_exclude_attribute_combination/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)