diff --git a/mrp_subcontracting_bom_dual_use/README.rst b/mrp_subcontracting_bom_dual_use/README.rst new file mode 100644 index 000000000..61ad64af2 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/README.rst @@ -0,0 +1,94 @@ +=============================== +Mrp subcontracting bom dual use +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:cafff56e6578794b77421691c0fa44a5f4daf8d002566a1eef763b360ec23198 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_subcontracting_bom_dual_use + :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_subcontracting_bom_dual_use + :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 allows subcontracting BOMs to be used for regular production orders as well. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to *Manufacturing > Products > Bill of materials* and create a new one with type = "Subcontracting". +#. Check "Allow in regular production". +#. Try to manufacture the product, and you will be able to use the previously created bill of materials. + +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 `_: + + * Víctor Martínez + * Pedro M. Baeza + +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-victoralmau| image:: https://github.com/victoralmau.png?size=40px + :target: https://github.com/victoralmau + :alt: victoralmau + +Current `maintainer `__: + +|maintainer-victoralmau| + +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_subcontracting_bom_dual_use/__init__.py b/mrp_subcontracting_bom_dual_use/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_subcontracting_bom_dual_use/__manifest__.py b/mrp_subcontracting_bom_dual_use/__manifest__.py new file mode 100644 index 000000000..9a368780a --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2022 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Mrp subcontracting bom dual use", + "version": "16.0.1.0.0", + "category": "Manufacturing", + "website": "https://github.com/OCA/manufacture", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["mrp_subcontracting"], + "installable": True, + "data": ["views/mrp_bom_view.xml"], + "maintainers": ["victoralmau"], +} diff --git a/mrp_subcontracting_bom_dual_use/i18n/es.po b/mrp_subcontracting_bom_dual_use/i18n/es.po new file mode 100644 index 000000000..41ca9ced8 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/i18n/es.po @@ -0,0 +1,61 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_subcontracting_bom_dual_use +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-08-16 15:24+0000\n" +"PO-Revision-Date: 2022-08-31 10:07+0000\n" +"Last-Translator: Víctor Martínez \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom__allow_in_regular_production +msgid "Allow in regular production" +msgstr "Permitir en fabricaciones regulares" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model,name:mrp_subcontracting_bom_dual_use.model_mrp_bom +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production__bom_id +msgid "Bill of Material" +msgstr "Lista de materiales" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,help:mrp_subcontracting_bom_dual_use.field_mrp_production__bom_id +msgid "" +"Bill of Materials allow you to define the list of required components to " +"make a finished product." +msgstr "" +"La lista de materiales le permite definir la lista de componentes necesarios " +"para hacer un producto terminado." + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom__display_name +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom__id +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production__id +msgid "ID" +msgstr "ID" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom____last_update +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model,name:mrp_subcontracting_bom_dual_use.model_mrp_production +msgid "Production Order" +msgstr "Orden de producción" diff --git a/mrp_subcontracting_bom_dual_use/i18n/it.po b/mrp_subcontracting_bom_dual_use/i18n/it.po new file mode 100644 index 000000000..958e11eec --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/i18n/it.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_subcontracting_bom_dual_use +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-05-15 19:34+0000\n" +"Last-Translator: Francesco Foresti \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom__allow_in_regular_production +msgid "Allow in regular production" +msgstr "Consenti in produzione regolare" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model,name:mrp_subcontracting_bom_dual_use.model_mrp_bom +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production__bom_id +msgid "Bill of Material" +msgstr "Distinta base" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,help:mrp_subcontracting_bom_dual_use.field_mrp_production__bom_id +msgid "" +"Bill of Materials allow you to define the list of required components to " +"make a finished product." +msgstr "" +"La distinta base consente di definire la lista dei componenti richiesti per " +"realizzare un prodotto." + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom__display_name +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom__id +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production__id +msgid "ID" +msgstr "ID" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom____last_update +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model,name:mrp_subcontracting_bom_dual_use.model_mrp_production +msgid "Production Order" +msgstr "Ordine di produzione" diff --git a/mrp_subcontracting_bom_dual_use/i18n/mrp_subcontracting_bom_dual_use.pot b/mrp_subcontracting_bom_dual_use/i18n/mrp_subcontracting_bom_dual_use.pot new file mode 100644 index 000000000..64e9be8d9 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/i18n/mrp_subcontracting_bom_dual_use.pot @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_subcontracting_bom_dual_use +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \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_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom__allow_in_regular_production +msgid "Allow in regular production" +msgstr "" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model,name:mrp_subcontracting_bom_dual_use.model_mrp_bom +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production__bom_id +msgid "Bill of Material" +msgstr "" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,help:mrp_subcontracting_bom_dual_use.field_mrp_production__bom_id +msgid "" +"Bill of Materials allow you to define the list of required components to " +"make a finished product." +msgstr "" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom__display_name +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production__display_name +msgid "Display Name" +msgstr "" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom__id +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production__id +msgid "ID" +msgstr "" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_bom____last_update +#: model:ir.model.fields,field_description:mrp_subcontracting_bom_dual_use.field_mrp_production____last_update +msgid "Last Modified on" +msgstr "" + +#. module: mrp_subcontracting_bom_dual_use +#: model:ir.model,name:mrp_subcontracting_bom_dual_use.model_mrp_production +msgid "Production Order" +msgstr "" diff --git a/mrp_subcontracting_bom_dual_use/models/__init__.py b/mrp_subcontracting_bom_dual_use/models/__init__.py new file mode 100644 index 000000000..18499c583 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import mrp_bom +from . import mrp_production diff --git a/mrp_subcontracting_bom_dual_use/models/mrp_bom.py b/mrp_subcontracting_bom_dual_use/models/mrp_bom.py new file mode 100644 index 000000000..906f3617a --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/models/mrp_bom.py @@ -0,0 +1,45 @@ +# Copyright 2022-2024 Tecnativa - Víctor Martínez +# 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" + + allow_in_regular_production = fields.Boolean(string="Allow in regular production") + + @api.constrains("operation_ids", "type", "allow_in_regular_production") + def _check_subcontracting_no_operation(self): + """Prevent ValidationError if 'Allow in regular production' is checked""" + domain = [ + ("type", "=", "subcontract"), + ("allow_in_regular_production", "=", False), + ("operation_ids", "!=", False), + ] + if self.filtered_domain(domain): + super()._check_subcontracting_no_operation() + return False + + @api.model + def _bom_find_domain( + self, products, picking_type=None, company_id=False, bom_type=False + ): + """We need to overwrite the domain to get subcontract boms""" + domain = super()._bom_find_domain( + products=products, + picking_type=picking_type, + company_id=company_id, + bom_type=bom_type, + ) + if bom_type == "normal": + domain_old = ("type", "=", "normal") + domain_new = [ + "|", + domain_old, + "&", + ("type", "=", "subcontract"), + ("allow_in_regular_production", "=", True), + ] + index = domain.index(domain_old) + domain = domain[:index] + domain_new + domain[index + 1 :] + return domain diff --git a/mrp_subcontracting_bom_dual_use/models/mrp_production.py b/mrp_subcontracting_bom_dual_use/models/mrp_production.py new file mode 100644 index 000000000..4ebcd4fbe --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/models/mrp_production.py @@ -0,0 +1,27 @@ +# Copyright 2022 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class MrpProduction(models.Model): + _inherit = "mrp.production" + + # Overwrite the field domain for adding subcontracting BoMs with the check + bom_id = fields.Many2one( + domain="""[ + '&', + '|', + ('company_id', '=', False), + ('company_id', '=', company_id), + '&', + '|', + ('product_id','=',product_id), + '&', + ('product_tmpl_id.product_variant_ids','=',product_id), + ('product_id','=',False), + '|', + ('type', '=', 'normal'), + '&', ('type', '=', 'subcontract'), ('allow_in_regular_production', '=', True) + ]""", + ) diff --git a/mrp_subcontracting_bom_dual_use/readme/CONTRIBUTORS.rst b/mrp_subcontracting_bom_dual_use/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..5fb713053 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Víctor Martínez + * Pedro M. Baeza diff --git a/mrp_subcontracting_bom_dual_use/readme/DESCRIPTION.rst b/mrp_subcontracting_bom_dual_use/readme/DESCRIPTION.rst new file mode 100644 index 000000000..6620a6d78 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows subcontracting BOMs to be used for regular production orders as well. diff --git a/mrp_subcontracting_bom_dual_use/readme/USAGE.rst b/mrp_subcontracting_bom_dual_use/readme/USAGE.rst new file mode 100644 index 000000000..43b936386 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/readme/USAGE.rst @@ -0,0 +1,3 @@ +#. Go to *Manufacturing > Products > Bill of materials* and create a new one with type = "Subcontracting". +#. Check "Allow in regular production". +#. Try to manufacture the product, and you will be able to use the previously created bill of materials. diff --git a/mrp_subcontracting_bom_dual_use/static/description/icon.png b/mrp_subcontracting_bom_dual_use/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mrp_subcontracting_bom_dual_use/static/description/icon.png differ diff --git a/mrp_subcontracting_bom_dual_use/static/description/index.html b/mrp_subcontracting_bom_dual_use/static/description/index.html new file mode 100644 index 000000000..f72d1a3d8 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Mrp subcontracting bom dual use + + + +
+

Mrp subcontracting bom dual use

+ + +

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

+

This module allows subcontracting BOMs to be used for regular production orders as well.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Manufacturing > Products > Bill of materials and create a new one with type = “Subcontracting”.
  2. +
  3. Check “Allow in regular production”.
  4. +
  5. Try to manufacture the product, and you will be able to use the previously created bill of materials.
  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 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:
      +
    • Víctor Martínez
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

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:

+

victoralmau

+

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_subcontracting_bom_dual_use/tests/__init__.py b/mrp_subcontracting_bom_dual_use/tests/__init__.py new file mode 100644 index 000000000..a595755fd --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_mrp_subcontracting_bom_dual_use diff --git a/mrp_subcontracting_bom_dual_use/tests/test_mrp_subcontracting_bom_dual_use.py b/mrp_subcontracting_bom_dual_use/tests/test_mrp_subcontracting_bom_dual_use.py new file mode 100644 index 000000000..b2a9dccf4 --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/tests/test_mrp_subcontracting_bom_dual_use.py @@ -0,0 +1,84 @@ +# Copyright 2022-2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.tests import Form, new_test_user +from odoo.tests.common import users + +from odoo.addons.base.tests.common import BaseCommon + + +class TestMrpSubcontractingBomDualUse(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.manufacture_route = cls.env.ref("mrp.route_warehouse0_manufacture") + cls.partner = cls.env["res.partner"].create({"name": "Mr Odoo"}) + cls.product = cls.env["product.product"].create( + { + "name": "Test product", + "type": "product", + "route_ids": [(6, 0, [cls.manufacture_route.id])], + } + ) + cls.component_a = cls.env["product.product"].create({"name": "Test Comp A"}) + cls.workcenter = cls.env["mrp.workcenter"].create({"name": "Test workcenter"}) + cls.mrp_production_model = cls.env["mrp.production"] + new_test_user( + cls.env, + login="test_mrp_routings_user", + groups="mrp.group_mrp_routings,mrp.group_mrp_manager", + ) + + def _create_bom(self, bom_type): + mrp_bom_form = Form(self.env["mrp.bom"]) + mrp_bom_form.product_tmpl_id = self.product.product_tmpl_id + mrp_bom_form.type = bom_type + if bom_type == "subcontract": + mrp_bom_form.subcontractor_ids.add(self.partner) + mrp_bom_form.allow_in_regular_production = True + mrp_bom_form.product_tmpl_id = self.product.product_tmpl_id + with mrp_bom_form.bom_line_ids.new() as line_form: + line_form.product_id = self.component_a + line_form.product_qty = 1 + return mrp_bom_form.save() + + def test_mrp_production_misc_bom_normal(self): + """We create a BOM of normal type. We create a production order and assign + the product to check that the BOM is assigned correctly.""" + bom = self._create_bom("normal") + mrp_production_form = Form(self.mrp_production_model) + mrp_production_form.product_id = self.product + self.assertEqual(mrp_production_form.bom_id, bom) + self.assertTrue(mrp_production_form.move_raw_ids) + + def test_mrp_production_misc_bom_subcontract(self): + """We create a BOM of subcontract type. We create a production order and assign + the product to check that the BOM is assigned correctly.""" + bom = self._create_bom("subcontract") + mrp_production_form = Form(self.mrp_production_model) + mrp_production_form.product_id = self.product + self.assertEqual(mrp_production_form.bom_id, bom) + self.assertTrue(mrp_production_form.move_raw_ids) + + def _product_replenish(self, product, qty): + replenish_form = Form( + self.env["product.replenish"].with_context(default_product_id=product.id) + ) + replenish_form.quantity = qty + replenish = replenish_form.save() + replenish.launch_replenishment() + + @users("test_mrp_routings_user") + def test_product_replenish(self): + """We create a bill of materials of subcontract type. We run replenish and + validate that the production order has been created with the correct BOM.""" + bom = self._create_bom("subcontract") + mrp_bom_form = Form(bom) + with mrp_bom_form.operation_ids.new() as operation_form: + operation_form.name = "Test operation" + operation_form.bom_id = bom + operation_form.workcenter_id = self.workcenter + bom = mrp_bom_form.save() + self._product_replenish(self.product, 1) + item = self.mrp_production_model.search([("product_id", "=", self.product.id)]) + self.assertEqual(item.bom_id, bom) + self.assertIn(self.workcenter, item.workorder_ids.mapped("workcenter_id")) diff --git a/mrp_subcontracting_bom_dual_use/views/mrp_bom_view.xml b/mrp_subcontracting_bom_dual_use/views/mrp_bom_view.xml new file mode 100644 index 000000000..eb336dd2d --- /dev/null +++ b/mrp_subcontracting_bom_dual_use/views/mrp_bom_view.xml @@ -0,0 +1,25 @@ + + + mrp.bom.form + mrp.bom + + + + + + + {'invisible': [('type', '=', 'subcontract'),('allow_in_regular_production','=',False)]} + + + {'invisible': [('type', '=', 'subcontract'),('allow_in_regular_production','=',False)]} + + + + diff --git a/setup/mrp_subcontracting_bom_dual_use/odoo/addons/mrp_subcontracting_bom_dual_use b/setup/mrp_subcontracting_bom_dual_use/odoo/addons/mrp_subcontracting_bom_dual_use new file mode 120000 index 000000000..88ca80b68 --- /dev/null +++ b/setup/mrp_subcontracting_bom_dual_use/odoo/addons/mrp_subcontracting_bom_dual_use @@ -0,0 +1 @@ +../../../../mrp_subcontracting_bom_dual_use \ No newline at end of file diff --git a/setup/mrp_subcontracting_bom_dual_use/setup.py b/setup/mrp_subcontracting_bom_dual_use/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_subcontracting_bom_dual_use/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)