From 918768f0b03a7cf8c4dd4116d0397646392c37ac Mon Sep 17 00:00:00 2001 From: Nikul-OSI Date: Thu, 22 Aug 2024 18:49:23 +0530 Subject: [PATCH] [ADD] product_configurator_sale_blanket_order_mrp: Added in v17 --- .../README.rst | 93 ++++ .../__init__.py | 5 + .../__manifest__.py | 24 + .../models/__init__.py | 3 + .../models/sale_blanket_order_line.py | 13 + .../pyproject.toml | 3 + .../readme/CONTRIBUTORS.md | 4 + .../readme/DESCRIPTION.md | 1 + .../static/description/index.html | 433 ++++++++++++++++++ .../tests/__init__.py | 1 + ...uct_configurator_sale_blanket_order_mrp.py | 85 ++++ .../views/sale_blanket_order_view.xml | 17 + .../wizard/__init__.py | 4 + .../wizard/create_sale_orders.py | 15 + .../wizard/product_configurator.py | 14 + 15 files changed, 715 insertions(+) create mode 100644 product_configurator_sale_blanket_order_mrp/README.rst create mode 100644 product_configurator_sale_blanket_order_mrp/__init__.py create mode 100644 product_configurator_sale_blanket_order_mrp/__manifest__.py create mode 100644 product_configurator_sale_blanket_order_mrp/models/__init__.py create mode 100644 product_configurator_sale_blanket_order_mrp/models/sale_blanket_order_line.py create mode 100644 product_configurator_sale_blanket_order_mrp/pyproject.toml create mode 100644 product_configurator_sale_blanket_order_mrp/readme/CONTRIBUTORS.md create mode 100644 product_configurator_sale_blanket_order_mrp/readme/DESCRIPTION.md create mode 100644 product_configurator_sale_blanket_order_mrp/static/description/index.html create mode 100644 product_configurator_sale_blanket_order_mrp/tests/__init__.py create mode 100644 product_configurator_sale_blanket_order_mrp/tests/test_product_configurator_sale_blanket_order_mrp.py create mode 100644 product_configurator_sale_blanket_order_mrp/views/sale_blanket_order_view.xml create mode 100644 product_configurator_sale_blanket_order_mrp/wizard/__init__.py create mode 100644 product_configurator_sale_blanket_order_mrp/wizard/create_sale_orders.py create mode 100644 product_configurator_sale_blanket_order_mrp/wizard/product_configurator.py diff --git a/product_configurator_sale_blanket_order_mrp/README.rst b/product_configurator_sale_blanket_order_mrp/README.rst new file mode 100644 index 000000000..246b4d957 --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/README.rst @@ -0,0 +1,93 @@ +====================================================== +Product Configurator Sales Blanket Order Manufacturing +====================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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_mrp + :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_mrp + :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 +Manufacturing. + +.. 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_mrp/__init__.py b/product_configurator_sale_blanket_order_mrp/__init__.py new file mode 100644 index 000000000..45d4be79c --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/__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_mrp/__manifest__.py b/product_configurator_sale_blanket_order_mrp/__manifest__.py new file mode 100644 index 000000000..24bff882f --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Product Configurator Sales Blanket Order Manufacturing", + "version": "17.0.1.0.0", + "category": "Manufacturing", + "summary": "BOM Support for sales Blanket Order wizard", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/product-configurator", + "depends": [ + "sale_blanket_order", + "product_configurator_sale_mrp", + "product_configurator_sale_blanket_order", + ], + "data": [ + "views/sale_blanket_order_view.xml", + ], + "installable": True, + "auto_install": True, + "development_status": "Alpha", + "maintainers": ["dreispt"], +} diff --git a/product_configurator_sale_blanket_order_mrp/models/__init__.py b/product_configurator_sale_blanket_order_mrp/models/__init__.py new file mode 100644 index 000000000..9cd616696 --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/models/__init__.py @@ -0,0 +1,3 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import sale_blanket_order_line diff --git a/product_configurator_sale_blanket_order_mrp/models/sale_blanket_order_line.py b/product_configurator_sale_blanket_order_mrp/models/sale_blanket_order_line.py new file mode 100644 index 000000000..21995d47f --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/models/sale_blanket_order_line.py @@ -0,0 +1,13 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class SaleBlanketOrderLine(models.Model): + _inherit = "sale.blanket.order.line" + + bom_id = fields.Many2one( + "mrp.bom", + string="BoM", + readonly=True, + ) diff --git a/product_configurator_sale_blanket_order_mrp/pyproject.toml b/product_configurator_sale_blanket_order_mrp/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_configurator_sale_blanket_order_mrp/readme/CONTRIBUTORS.md b/product_configurator_sale_blanket_order_mrp/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..aaec96329 --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/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_mrp/readme/DESCRIPTION.md b/product_configurator_sale_blanket_order_mrp/readme/DESCRIPTION.md new file mode 100644 index 000000000..24d163b13 --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Product Configurator wizard available on Sale Blanket Orders Manufacturing. diff --git a/product_configurator_sale_blanket_order_mrp/static/description/index.html b/product_configurator_sale_blanket_order_mrp/static/description/index.html new file mode 100644 index 000000000..605b86f98 --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/static/description/index.html @@ -0,0 +1,433 @@ + + + + + +Product Configurator Sales Blanket Order Manufacturing + + + +
+

Product Configurator Sales Blanket Order Manufacturing

+ + +

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

+

Product Configurator wizard available on Sale Blanket Orders +Manufacturing.

+
+

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_mrp/tests/__init__.py b/product_configurator_sale_blanket_order_mrp/tests/__init__.py new file mode 100644 index 000000000..9c579413e --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_configurator_sale_blanket_order_mrp diff --git a/product_configurator_sale_blanket_order_mrp/tests/test_product_configurator_sale_blanket_order_mrp.py b/product_configurator_sale_blanket_order_mrp/tests/test_product_configurator_sale_blanket_order_mrp.py new file mode 100644 index 000000000..dd5a30dd1 --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/tests/test_product_configurator_sale_blanket_order_mrp.py @@ -0,0 +1,85 @@ +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.mrpBom = self.env["mrp.bom"] + 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()", + ) + self.assertFalse(sale_blanket_order_id.line_ids.mapped("bom_id")) + + # create bom + self.bom_id = self.mrpBom.create( + { + "product_tmpl_id": product_tmpl.id, + "product_id": sale_blanket_order_id.line_ids.product_id.id, + "product_qty": 1.00, + "type": "normal", + "ready_to_produce": "all_available", + } + ) + sale_blanket_order = 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, + wizard_model="product.configurator.sale.blanket.order", + ) + self.ProductConfWizard = self.env[ + "product.configurator.sale.blanket.order" + ].with_context(**context) + sale_blanket_order.action_config_start() + self._configure_product_nxt_step() + sale_blanket_order.line_ids.reconfigure_product() + self.assertTrue(sale_blanket_order.line_ids.mapped("bom_id")) diff --git a/product_configurator_sale_blanket_order_mrp/views/sale_blanket_order_view.xml b/product_configurator_sale_blanket_order_mrp/views/sale_blanket_order_view.xml new file mode 100644 index 000000000..950b9967a --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/views/sale_blanket_order_view.xml @@ -0,0 +1,17 @@ + + + + sale.blanket.order.form.configurator..mrp.inherit + sale.blanket.order + + + + + + + + + diff --git a/product_configurator_sale_blanket_order_mrp/wizard/__init__.py b/product_configurator_sale_blanket_order_mrp/wizard/__init__.py new file mode 100644 index 000000000..da8e8b058 --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/wizard/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import product_configurator +from . import create_sale_orders diff --git a/product_configurator_sale_blanket_order_mrp/wizard/create_sale_orders.py b/product_configurator_sale_blanket_order_mrp/wizard/create_sale_orders.py new file mode 100644 index 000000000..0e48632ec --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/wizard/create_sale_orders.py @@ -0,0 +1,15 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import models + + +class BlanketOrderWizard(models.TransientModel): + _inherit = "sale.blanket.order.wizard" + + def _prepare_so_line_vals(self, line): + vals = super()._prepare_so_line_vals(line) + bom = self.env["mrp.bom"].search( + [("product_id", "=", line.product_id.id)], limit=1 + ) + vals.update(bom_id=bom.id) + return vals diff --git a/product_configurator_sale_blanket_order_mrp/wizard/product_configurator.py b/product_configurator_sale_blanket_order_mrp/wizard/product_configurator.py new file mode 100644 index 000000000..d125139f4 --- /dev/null +++ b/product_configurator_sale_blanket_order_mrp/wizard/product_configurator.py @@ -0,0 +1,14 @@ +# Copyright (C) 2024 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import models + + +class ProductConfiguratorSaleBlanketOrder(models.TransientModel): + _inherit = "product.configurator.sale.blanket.order" + + def _get_order_line_vals(self, product_id): + """Add the config session related bom_id to the sale blanket order""" + vals = super()._get_order_line_vals(product_id=product_id) + bom = self.env["mrp.bom"].search([("product_id", "=", product_id)], limit=1) + vals.update(bom_id=bom.id) + return vals