diff --git a/mrp_bom_select_product_variant/README.rst b/mrp_bom_select_product_variant/README.rst new file mode 100644 index 000000000..0b37691e9 --- /dev/null +++ b/mrp_bom_select_product_variant/README.rst @@ -0,0 +1,83 @@ +============================== +MRP BoM Select Product Variant +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5b23ce3e5b73bf6db5a6b6f719c9ad41ed9ac621633e23e546e392f11180d630 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fmanufacture-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/16.0/mrp_bom_select_product_variant + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_select_product_variant + :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/manufacture&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module is designed so that the user selects the product variant when +creating or updating a Bill of Material. +When selecting a product variant, the linked product template is +automatically selected. + +Tree and filter view are also changed : you see and search with product variant. + +.. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_select_product_variant/static/description/mrp_bom_select_product_variant.gif + +**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 +~~~~~~~ + +* GRAP + +Contributors +~~~~~~~~~~~~ + +* Quentin Dupont (quentin.dupont@grap.coop) + +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. + +This module is part of the `OCA/manufacture `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_bom_select_product_variant/__init__.py b/mrp_bom_select_product_variant/__init__.py new file mode 100644 index 000000000..9186ee3ad --- /dev/null +++ b/mrp_bom_select_product_variant/__init__.py @@ -0,0 +1 @@ +from . import model diff --git a/mrp_bom_select_product_variant/__manifest__.py b/mrp_bom_select_product_variant/__manifest__.py new file mode 100644 index 000000000..c1eebbfd1 --- /dev/null +++ b/mrp_bom_select_product_variant/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Quentin Dupont (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "MRP BoM Select Product Variant", + "summary": "Favors Product variant selection for BOM creation.", + "version": "16.0.1.0.0", + "author": "GRAP, Odoo Community Association (OCA)", + "category": "Manufacturing", + "depends": ["mrp"], + "website": "https://github.com/OCA/manufacture", + "license": "AGPL-3", + "data": [ + "view/mrp_bom.xml", + ], + "installable": True, +} diff --git a/mrp_bom_select_product_variant/i18n/fr.po b/mrp_bom_select_product_variant/i18n/fr.po new file mode 100644 index 000000000..c492d2974 --- /dev/null +++ b/mrp_bom_select_product_variant/i18n/fr.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_bom_select_product_variant +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-03-20 11:20+0000\n" +"PO-Revision-Date: 2024-03-20 11:20+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mrp_bom_select_product_variant +#: model:ir.model,name:mrp_bom_select_product_variant.model_mrp_bom +msgid "Bill of Material" +msgstr "Nomenclature" + +#. module: mrp_bom_select_product_variant +#: model:ir.model.fields,help:mrp_bom_select_product_variant.field_mrp_bom__product_id +msgid "" +"If a product variant is defined the BOM is available only for this product." +msgstr "" +"Si une variante de produit est définie, la nomenclature n'est disponible que" +" pour ce produit." + +#. module: mrp_bom_select_product_variant +#: model:ir.model.fields,field_description:mrp_bom_select_product_variant.field_mrp_bom__product_id +#: model_terms:ir.ui.view,arch_db:mrp_bom_select_product_variant.view_mrp_bom_search +msgid "Product Variant" +msgstr "Variante de produit" diff --git a/mrp_bom_select_product_variant/model/__init__.py b/mrp_bom_select_product_variant/model/__init__.py new file mode 100644 index 000000000..a352efe9b --- /dev/null +++ b/mrp_bom_select_product_variant/model/__init__.py @@ -0,0 +1 @@ +from . import mrp_bom diff --git a/mrp_bom_select_product_variant/model/mrp_bom.py b/mrp_bom_select_product_variant/model/mrp_bom.py new file mode 100644 index 000000000..3604ccaeb --- /dev/null +++ b/mrp_bom_select_product_variant/model/mrp_bom.py @@ -0,0 +1,22 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Quentin DUPONT (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class MrpBom(models.Model): + _inherit = "mrp.bom" + + # As this field is used on a priority basis, it must be possible to + # select any type of product concerned + product_id = fields.Many2one( + domain="[('type', 'in', ['product', 'consu']), '|'," + "('company_id', '=', False), ('company_id', '=', company_id)]", + ) + + # Side effect : if you change product_tmpl_id, it will reset it because + # of loop of onchange_product_tmpl_id in Odoo code + @api.onchange("product_id") + def _onchange_product_id(self): + self.product_tmpl_id = self.product_id.product_tmpl_id diff --git a/mrp_bom_select_product_variant/readme/CONTRIBUTORS.rst b/mrp_bom_select_product_variant/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9ed470628 --- /dev/null +++ b/mrp_bom_select_product_variant/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Quentin Dupont (quentin.dupont@grap.coop) diff --git a/mrp_bom_select_product_variant/readme/DESCRIPTION.rst b/mrp_bom_select_product_variant/readme/DESCRIPTION.rst new file mode 100644 index 000000000..ed577523f --- /dev/null +++ b/mrp_bom_select_product_variant/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +This module is designed so that the user selects the product variant when +creating or updating a Bill of Material. +When selecting a product variant, the linked product template is +automatically selected. + +Tree and filter view are also changed : you see and search with product variant. + +.. figure:: ../static/description/mrp_bom_select_product_variant.gif diff --git a/mrp_bom_select_product_variant/static/description/index.html b/mrp_bom_select_product_variant/static/description/index.html new file mode 100644 index 000000000..acd853751 --- /dev/null +++ b/mrp_bom_select_product_variant/static/description/index.html @@ -0,0 +1,428 @@ + + + + + + +MRP BoM Select Product Variant + + + +
+

MRP BoM Select Product Variant

+ + +

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

+

This module is designed so that the user selects the product variant when +creating or updating a Bill of Material. +When selecting a product variant, the linked product template is +automatically selected.

+

Tree and filter view are also changed : you see and search with product variant.

+
+https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_select_product_variant/static/description/mrp_bom_select_product_variant.gif +
+

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

+
    +
  • GRAP
  • +
+
+
+

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.

+

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

+

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

+
+
+
+ + diff --git a/mrp_bom_select_product_variant/static/description/mrp_bom_select_product_variant.gif b/mrp_bom_select_product_variant/static/description/mrp_bom_select_product_variant.gif new file mode 100644 index 000000000..628c35b5b Binary files /dev/null and b/mrp_bom_select_product_variant/static/description/mrp_bom_select_product_variant.gif differ diff --git a/mrp_bom_select_product_variant/tests/__init__.py b/mrp_bom_select_product_variant/tests/__init__.py new file mode 100644 index 000000000..e103d6e8d --- /dev/null +++ b/mrp_bom_select_product_variant/tests/__init__.py @@ -0,0 +1 @@ +from . import test_bom_product_variant diff --git a/mrp_bom_select_product_variant/tests/test_bom_product_variant.py b/mrp_bom_select_product_variant/tests/test_bom_product_variant.py new file mode 100644 index 000000000..cdf578a8c --- /dev/null +++ b/mrp_bom_select_product_variant/tests/test_bom_product_variant.py @@ -0,0 +1,20 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Quentin DUPONT (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import TransactionCase + + +class TestBomProductVariant(TransactionCase): + def setUp(self): + super(TestBomProductVariant, self).setUp() + self.product_product_desk = self.env.ref("product.product_product_3") + self.bom_desk = self.env.ref("mrp.mrp_bom_manufacture") + + def test_01_add_variant_in_bom(self): + self.bom_desk.write({"product_id": self.product_product_desk.id}) + self.bom_desk._onchange_product_id() + self.assertEqual( + self.bom_desk.product_tmpl_id, + self.bom_desk.product_id.product_tmpl_id, + ) diff --git a/mrp_bom_select_product_variant/view/mrp_bom.xml b/mrp_bom_select_product_variant/view/mrp_bom.xml new file mode 100644 index 000000000..b2decce74 --- /dev/null +++ b/mrp_bom_select_product_variant/view/mrp_bom.xml @@ -0,0 +1,81 @@ + + + + + + + + + + mrp.bom + + + + 1 + + + + + + + + + + + + + mrp.bom + + + + 1 + + + + 1 + + + + + + + + + + + + + + mrp.bom + + + + + + + + 1 + + + + + + + 1 + + + + + diff --git a/setup/mrp_bom_select_product_variant/odoo/addons/mrp_bom_select_product_variant b/setup/mrp_bom_select_product_variant/odoo/addons/mrp_bom_select_product_variant new file mode 120000 index 000000000..4d7d39137 --- /dev/null +++ b/setup/mrp_bom_select_product_variant/odoo/addons/mrp_bom_select_product_variant @@ -0,0 +1 @@ +../../../../mrp_bom_select_product_variant \ No newline at end of file diff --git a/setup/mrp_bom_select_product_variant/setup.py b/setup/mrp_bom_select_product_variant/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_bom_select_product_variant/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)