From 920ac770da4ffa86653b7730dccef0c438abd68c Mon Sep 17 00:00:00 2001 From: Nikul-OSI Date: Thu, 22 Aug 2024 15:02:34 +0530 Subject: [PATCH] [ADD] product_configurator_sale_blanket_order: Added in v17 --- .../README.rst | 92 ++++ .../__init__.py | 5 + .../__manifest__.py | 21 + .../models/__init__.py | 5 + .../models/sale_blanket_order.py | 18 + .../models/sale_blanket_order_line.py | 55 +++ .../pyproject.toml | 3 + .../readme/CONTRIBUTORS.md | 4 + .../readme/DESCRIPTION.md | 1 + .../security/ir.model.access.csv | 3 + .../static/description/index.html | 432 ++++++++++++++++++ .../tests/__init__.py | 1 + ...product_configurator_sale_blanket_order.py | 53 +++ .../views/sale_blanket_order_view.xml | 54 +++ .../wizard/__init__.py | 4 + .../wizard/product_configurator.py | 118 +++++ 16 files changed, 869 insertions(+) create mode 100644 product_configurator_sale_blanket_order/README.rst create mode 100644 product_configurator_sale_blanket_order/__init__.py create mode 100644 product_configurator_sale_blanket_order/__manifest__.py create mode 100644 product_configurator_sale_blanket_order/models/__init__.py create mode 100644 product_configurator_sale_blanket_order/models/sale_blanket_order.py create mode 100644 product_configurator_sale_blanket_order/models/sale_blanket_order_line.py create mode 100644 product_configurator_sale_blanket_order/pyproject.toml create mode 100644 product_configurator_sale_blanket_order/readme/CONTRIBUTORS.md create mode 100644 product_configurator_sale_blanket_order/readme/DESCRIPTION.md create mode 100644 product_configurator_sale_blanket_order/security/ir.model.access.csv create mode 100644 product_configurator_sale_blanket_order/static/description/index.html create mode 100644 product_configurator_sale_blanket_order/tests/__init__.py create mode 100644 product_configurator_sale_blanket_order/tests/test_product_configurator_sale_blanket_order.py create mode 100644 product_configurator_sale_blanket_order/views/sale_blanket_order_view.xml create mode 100644 product_configurator_sale_blanket_order/wizard/__init__.py create mode 100644 product_configurator_sale_blanket_order/wizard/product_configurator.py diff --git a/product_configurator_sale_blanket_order/README.rst b/product_configurator_sale_blanket_order/README.rst new file mode 100644 index 0000000000..b5c879cb71 --- /dev/null +++ b/product_configurator_sale_blanket_order/README.rst @@ -0,0 +1,92 @@ +======================================== +Product Configurator Sales Blanket Order +======================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8ac72b616a5da10e2b4aba32514c4f59ff147e3834228a7e281ae7c723d8c496 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Fproduct--configurator-lightgray.png?logo=github + :target: https://github.com/OCA/product-configurator/tree/17.0/product_configurator_sale_blanket_order + :alt: OCA/product-configurator +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/product-configurator-17-0/product-configurator-17-0-product_configurator_sale_blanket_order + :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/product-configurator&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Product Configurator wizard available on Sale Blanket Orders. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* Open Source Integrators + +Contributors +------------ + +- `Open Source Integrators `__. + + - Patrick Wilson + - Nikul Chaudhary + +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-dreispt| image:: https://github.com/dreispt.png?size=40px + :target: https://github.com/dreispt + :alt: dreispt + +Current `maintainer `__: + +|maintainer-dreispt| + +This module is part of the `OCA/product-configurator `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_configurator_sale_blanket_order/__init__.py b/product_configurator_sale_blanket_order/__init__.py new file mode 100644 index 0000000000..45d4be79c0 --- /dev/null +++ b/product_configurator_sale_blanket_order/__init__.py @@ -0,0 +1,5 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models +from . import wizard diff --git a/product_configurator_sale_blanket_order/__manifest__.py b/product_configurator_sale_blanket_order/__manifest__.py new file mode 100644 index 0000000000..055d408895 --- /dev/null +++ b/product_configurator_sale_blanket_order/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Product Configurator Sales Blanket Order", + "version": "17.0.1.0.0", + "category": "Sale", + "summary": "Product configuration interface modules for Sales Blanket Order", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/product-configurator", + "depends": ["sale_blanket_order", "product_configurator"], + "data": [ + "security/ir.model.access.csv", + "views/sale_blanket_order_view.xml", + ], + "installable": True, + "auto_install": True, + "development_status": "Alpha", + "maintainers": ["dreispt"], +} diff --git a/product_configurator_sale_blanket_order/models/__init__.py b/product_configurator_sale_blanket_order/models/__init__.py new file mode 100644 index 0000000000..8fa002eb85 --- /dev/null +++ b/product_configurator_sale_blanket_order/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import sale_blanket_order +from . import sale_blanket_order_line diff --git a/product_configurator_sale_blanket_order/models/sale_blanket_order.py b/product_configurator_sale_blanket_order/models/sale_blanket_order.py new file mode 100644 index 0000000000..9719db7b6f --- /dev/null +++ b/product_configurator_sale_blanket_order/models/sale_blanket_order.py @@ -0,0 +1,18 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import models + + +class SaleBlanketOrder(models.Model): + _inherit = "sale.blanket.order" + + def action_config_start(self): + """Return action to start configuration wizard""" + configurator_obj = self.env["product.configurator.sale.blanket.order"] + ctx = dict( + self.env.context, + default_order_id=self.id, + wizard_model="product.configurator.sale.blanket.order", + allow_preset_selection=True, + ) + return configurator_obj.with_context(**ctx).get_wizard_action() diff --git a/product_configurator_sale_blanket_order/models/sale_blanket_order_line.py b/product_configurator_sale_blanket_order/models/sale_blanket_order_line.py new file mode 100644 index 0000000000..f253806566 --- /dev/null +++ b/product_configurator_sale_blanket_order/models/sale_blanket_order_line.py @@ -0,0 +1,55 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class SaleBlanketOrderLine(models.Model): + _inherit = "sale.blanket.order.line" + + custom_value_ids = fields.One2many( + comodel_name="product.config.session.custom.value", + inverse_name="cfg_session_id", + related="config_session_id.custom_value_ids", + string="Configurator Custom Values", + ) + config_ok = fields.Boolean( + related="product_id.config_ok", string="Configurable", readonly=True + ) + config_session_id = fields.Many2one( + comodel_name="product.config.session", string="Config Session" + ) + state = fields.Selection(related="order_id.state") + + def reconfigure_product(self): + """Creates and launches a product configurator wizard with a linked + template and variant in order to re-configure a existing product. It is + esetially a shortcut to pre-fill configuration data of a variant""" + wizard_model = "product.configurator.sale.blanket.order" + + extra_vals = { + "order_id": self.order_id.id, + "order_line_id": self.id, + "product_id": self.product_id.id, + } + self = self.with_context( + default_order_id=self.order_id.id, + default_order_line_id=self.id, + ) + return self.product_id.product_tmpl_id.create_config_wizard( + model_name=wizard_model, extra_vals=extra_vals + ) + + @api.depends("product_id") + def _compute_name(self): + for line in self: + name = "" + custom_values = line.custom_value_ids + if custom_values: + name += "\n" + "\n".join( + [f"{cv.display_name}: {cv.value}" for cv in custom_values] + ) + else: + if not line.product_id: + continue + name = self.product_id.get_product_multiline_description_sale() + line.name = name diff --git a/product_configurator_sale_blanket_order/pyproject.toml b/product_configurator_sale_blanket_order/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/product_configurator_sale_blanket_order/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_configurator_sale_blanket_order/readme/CONTRIBUTORS.md b/product_configurator_sale_blanket_order/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..aaec96329e --- /dev/null +++ b/product_configurator_sale_blanket_order/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [Open Source Integrators](https://opensourceintegrators.com). + + - Patrick Wilson \<\> + - Nikul Chaudhary \<\> \ No newline at end of file diff --git a/product_configurator_sale_blanket_order/readme/DESCRIPTION.md b/product_configurator_sale_blanket_order/readme/DESCRIPTION.md new file mode 100644 index 0000000000..73b3bad5c5 --- /dev/null +++ b/product_configurator_sale_blanket_order/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Product Configurator wizard available on Sale Blanket Orders. diff --git a/product_configurator_sale_blanket_order/security/ir.model.access.csv b/product_configurator_sale_blanket_order/security/ir.model.access.csv new file mode 100644 index 0000000000..c3fad21e1b --- /dev/null +++ b/product_configurator_sale_blanket_order/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_configurator_blanket_order,product_configurator_sale_blanket_order,model_product_configurator_sale_blanket_order,base.group_user,1,0,0,0 +access_product_configurator_blanket_order_manager,product_configurator_sale_blanket_order,model_product_configurator_sale_blanket_order,product_configurator.group_product_configurator_manager,1,1,1,1 diff --git a/product_configurator_sale_blanket_order/static/description/index.html b/product_configurator_sale_blanket_order/static/description/index.html new file mode 100644 index 0000000000..5007173077 --- /dev/null +++ b/product_configurator_sale_blanket_order/static/description/index.html @@ -0,0 +1,432 @@ + + + + + +Product Configurator Sales Blanket Order + + + +
+

Product Configurator Sales Blanket Order

+ + +

Alpha License: AGPL-3 OCA/product-configurator Translate me on Weblate Try me on Runboat

+

Product Configurator wizard available on Sale Blanket Orders.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

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

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

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:

+

dreispt

+

This module is part of the OCA/product-configurator project on GitHub.

+

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

+
+
+
+ + diff --git a/product_configurator_sale_blanket_order/tests/__init__.py b/product_configurator_sale_blanket_order/tests/__init__.py new file mode 100644 index 0000000000..d8e140becb --- /dev/null +++ b/product_configurator_sale_blanket_order/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_configurator_sale_blanket_order diff --git a/product_configurator_sale_blanket_order/tests/test_product_configurator_sale_blanket_order.py b/product_configurator_sale_blanket_order/tests/test_product_configurator_sale_blanket_order.py new file mode 100644 index 0000000000..f85e09d851 --- /dev/null +++ b/product_configurator_sale_blanket_order/tests/test_product_configurator_sale_blanket_order.py @@ -0,0 +1,53 @@ +from datetime import date, timedelta + +from odoo import fields + +from odoo.addons.product_configurator.tests import ( + test_product_configurator_test_cases as TC, +) + + +class SaleOrder(TC.ProductConfiguratorTestCases): + def setUp(self): + super().setUp() + self.SaleBlanketOrderId = self.env["sale.blanket.order"] + self.productPricelist = self.env["product.pricelist"] + self.resPartner = self.env.user.partner_id + self.currency_id = self.env.ref("base.USD") + self.ProductConfWizard = self.env["product.configurator.sale.blanket.order"] + self.payment_term = self.env.ref("account.account_payment_term_immediate") + self.tomorrow = date.today() + timedelta(days=1) + + def test_00_reconfigure_product(self): + pricelist_id = self.productPricelist.create( + { + "name": "Test Pricelist", + "currency_id": self.currency_id.id, + } + ) + sale_blanket_order_id = self.SaleBlanketOrderId.create( + { + "partner_id": self.resPartner.id, + "pricelist_id": pricelist_id.id, + "validity_date": fields.Date.to_string(self.tomorrow), + "payment_term_id": self.payment_term.id, + } + ) + context = dict( + default_order_id=sale_blanket_order_id.id, + wizard_model="product.configurator.sale.blanket.order", + ) + + self.ProductConfWizard = self.env[ + "product.configurator.sale.blanket.order" + ].with_context(**context) + sale_blanket_order_id.action_config_start() + self._configure_product_nxt_step() + sale_blanket_order_id.line_ids.reconfigure_product() + product_tmpl = sale_blanket_order_id.line_ids.product_id.product_tmpl_id + self.assertEqual( + product_tmpl.id, + self.config_product.id, + "Error: If product_tmpl not exsits\ + Method: action_config_start()", + ) diff --git a/product_configurator_sale_blanket_order/views/sale_blanket_order_view.xml b/product_configurator_sale_blanket_order/views/sale_blanket_order_view.xml new file mode 100644 index 0000000000..3bab008c78 --- /dev/null +++ b/product_configurator_sale_blanket_order/views/sale_blanket_order_view.xml @@ -0,0 +1,54 @@ + + + + sale.blanket.order.form.configurator.inherit + sale.blanket.order + + + +