diff --git a/mrp_production_picking_type_from_route/README.rst b/mrp_production_picking_type_from_route/README.rst new file mode 100644 index 000000000..d984fc263 --- /dev/null +++ b/mrp_production_picking_type_from_route/README.rst @@ -0,0 +1,87 @@ +====================================== +MRP Production Picking Type From Route +====================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:f1383a1e86a8864d407c8883419866e78ff9c2088c09c18356946909eb612b71 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/15.0/mrp_production_picking_type_from_route + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-mrp_production_picking_type_from_route + :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=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module add an onchange that updates the operation type based on the +product while creating a new MO manually. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Go to *Manufacturing > Manufacturing Orders*. +#. Create a new MO. +#. Select a product, the operation type has been updated based on the routes + configured for that product. + +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 +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Lois Rilo + +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_production_picking_type_from_route/__init__.py b/mrp_production_picking_type_from_route/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mrp_production_picking_type_from_route/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_production_picking_type_from_route/__manifest__.py b/mrp_production_picking_type_from_route/__manifest__.py new file mode 100644 index 000000000..24c2ca0d0 --- /dev/null +++ b/mrp_production_picking_type_from_route/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "MRP Production Picking Type From Route", + "summary": "Updates the operation type creating MO based on the product", + "version": "15.0.1.0.0", + "category": "Manufacture", + "website": "https://github.com/OCA/manufacture", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "depends": ["mrp"], + "installable": True, +} diff --git a/mrp_production_picking_type_from_route/i18n/it.po b/mrp_production_picking_type_from_route/i18n/it.po new file mode 100644 index 000000000..2616a0181 --- /dev/null +++ b/mrp_production_picking_type_from_route/i18n/it.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_production_picking_type_from_route +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-05-29 13:10+0000\n" +"Last-Translator: mymage \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.17\n" + +#. module: mrp_production_picking_type_from_route +#: model:ir.model.fields,field_description:mrp_production_picking_type_from_route.field_mrp_production__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: mrp_production_picking_type_from_route +#: model:ir.model.fields,field_description:mrp_production_picking_type_from_route.field_mrp_production__id +msgid "ID" +msgstr "ID" + +#. module: mrp_production_picking_type_from_route +#: model:ir.model.fields,field_description:mrp_production_picking_type_from_route.field_mrp_production____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: mrp_production_picking_type_from_route +#: model:ir.model,name:mrp_production_picking_type_from_route.model_mrp_production +msgid "Production Order" +msgstr "Ordine di produzione" diff --git a/mrp_production_picking_type_from_route/i18n/mrp_production_picking_type_from_route.pot b/mrp_production_picking_type_from_route/i18n/mrp_production_picking_type_from_route.pot new file mode 100644 index 000000000..a67f79a95 --- /dev/null +++ b/mrp_production_picking_type_from_route/i18n/mrp_production_picking_type_from_route.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_production_picking_type_from_route +# +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_production_picking_type_from_route +#: model:ir.model.fields,field_description:mrp_production_picking_type_from_route.field_mrp_production__display_name +msgid "Display Name" +msgstr "" + +#. module: mrp_production_picking_type_from_route +#: model:ir.model.fields,field_description:mrp_production_picking_type_from_route.field_mrp_production__id +msgid "ID" +msgstr "" + +#. module: mrp_production_picking_type_from_route +#: model:ir.model.fields,field_description:mrp_production_picking_type_from_route.field_mrp_production____last_update +msgid "Last Modified on" +msgstr "" + +#. module: mrp_production_picking_type_from_route +#: model:ir.model,name:mrp_production_picking_type_from_route.model_mrp_production +msgid "Production Order" +msgstr "" diff --git a/mrp_production_picking_type_from_route/models/__init__.py b/mrp_production_picking_type_from_route/models/__init__.py new file mode 100644 index 000000000..a9e5f13e4 --- /dev/null +++ b/mrp_production_picking_type_from_route/models/__init__.py @@ -0,0 +1 @@ +from . import mrp_production diff --git a/mrp_production_picking_type_from_route/models/mrp_production.py b/mrp_production_picking_type_from_route/models/mrp_production.py new file mode 100644 index 000000000..5c45b2c64 --- /dev/null +++ b/mrp_production_picking_type_from_route/models/mrp_production.py @@ -0,0 +1,29 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class MrpProduction(models.Model): + _inherit = "mrp.production" + + # Skip picking_type_id as a onchange trigger, even though the + # extended method is an onchange for picking_type_id too. + # If triggered also from picking_type_id changes, it would be impossible + # to adjust picking_type_id manually. + @api.onchange("product_id", "company_id") + def _onchange_product_id(self): + res = super()._onchange_product_id() + if self.product_id: + base_domain = [ + ("action", "=", "manufacture"), + "|", + ("company_id", "=", False), + ("company_id", "child_of", self.company_id.id), + ] + res_rule = self.env["procurement.group"]._search_rule( + False, False, self.product_id, False, base_domain + ) + if res_rule: + self.picking_type_id = res_rule.picking_type_id + return res diff --git a/mrp_production_picking_type_from_route/readme/CONTRIBUTORS.rst b/mrp_production_picking_type_from_route/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..77dfbe89e --- /dev/null +++ b/mrp_production_picking_type_from_route/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Lois Rilo diff --git a/mrp_production_picking_type_from_route/readme/DESCRIPTION.rst b/mrp_production_picking_type_from_route/readme/DESCRIPTION.rst new file mode 100644 index 000000000..3615701e5 --- /dev/null +++ b/mrp_production_picking_type_from_route/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module add an onchange that updates the operation type based on the +product while creating a new MO manually. diff --git a/mrp_production_picking_type_from_route/readme/USAGE.rst b/mrp_production_picking_type_from_route/readme/USAGE.rst new file mode 100644 index 000000000..c3273ca06 --- /dev/null +++ b/mrp_production_picking_type_from_route/readme/USAGE.rst @@ -0,0 +1,6 @@ +To use this module, you need to: + +#. Go to *Manufacturing > Manufacturing Orders*. +#. Create a new MO. +#. Select a product, the operation type has been updated based on the routes + configured for that product. diff --git a/mrp_production_picking_type_from_route/static/description/icon.png b/mrp_production_picking_type_from_route/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mrp_production_picking_type_from_route/static/description/icon.png differ diff --git a/mrp_production_picking_type_from_route/static/description/index.html b/mrp_production_picking_type_from_route/static/description/index.html new file mode 100644 index 000000000..465597c78 --- /dev/null +++ b/mrp_production_picking_type_from_route/static/description/index.html @@ -0,0 +1,432 @@ + + + + + +MRP Production Picking Type From Route + + + +
+

MRP Production Picking Type From Route

+ + +

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

+

This module add an onchange that updates the operation type based on the +product while creating a new MO manually.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Manufacturing > Manufacturing Orders.
  2. +
  3. Create a new MO.
  4. +
  5. Select a product, the operation type has been updated based on the routes +configured for that product.
  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

+
    +
  • ForgeFlow
  • +
+
+ +
+

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_production_picking_type_from_route/tests/__init__.py b/mrp_production_picking_type_from_route/tests/__init__.py new file mode 100644 index 000000000..aa36a5d32 --- /dev/null +++ b/mrp_production_picking_type_from_route/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mrp_production_picking_type_from_route diff --git a/mrp_production_picking_type_from_route/tests/test_mrp_production_picking_type_from_route.py b/mrp_production_picking_type_from_route/tests/test_mrp_production_picking_type_from_route.py new file mode 100644 index 000000000..bd359faa6 --- /dev/null +++ b/mrp_production_picking_type_from_route/tests/test_mrp_production_picking_type_from_route.py @@ -0,0 +1,81 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests import Form +from odoo.tests.common import TransactionCase + + +class MrpProductionCase(TransactionCase): + def setUp(self): + super(MrpProductionCase, self).setUp() + self.product_model = self.env["product.product"] + self.bom_model = self.env["mrp.bom"] + self.route_model = self.env["stock.location.route"] + self.loc_model = self.env["stock.location"] + self.op_type_model = self.env["stock.picking.type"] + + self.wh = self.env.ref("stock.warehouse0") + self.standard_manuf_route = self.env.ref("mrp.route_warehouse0_manufacture") + self.standard_manuf_op_type = self.wh.manu_type_id + + self.product_1 = self.product_model.create( + {"name": "Product 1", "route_ids": [(6, 0, self.standard_manuf_route.ids)]} + ) + + self.source_loc_2 = self.loc_model.create( + { + "name": "Pre Production 2", + "location_id": self.wh.view_location_id.id, + "usage": "internal", + } + ) + self.op_type_2 = self.op_type_model.create( + { + "name": "Secondary Manufacturing", + "code": "mrp_operation", + "sequence_code": "MO/SEC", + "default_location_src_id": self.source_loc_2.id, + "default_location_dest_id": self.wh.lot_stock_id.id, + } + ) + self.secondary_manuf_route = self.route_model.create( + { + "name": "Secondary Manufacture", + "rule_ids": [ + ( + 0, + 0, + { + "name": "Manufacture with secondary op", + "action": "manufacture", + "picking_type_id": self.op_type_2.id, + "location_src_id": self.source_loc_2.id, + "location_id": self.wh.lot_stock_id.id, + }, + ) + ], + } + ) + self.product_2 = self.product_model.create( + {"name": "Product 2", "route_ids": [(6, 0, self.secondary_manuf_route.ids)]} + ) + + def test_01_create_mo_and_change_product(self): + new_mo = Form(self.env["mrp.production"]) + new_mo.product_id = self.product_1 + self.assertEqual(new_mo.picking_type_id, self.standard_manuf_op_type) + new_mo.product_id = self.product_2 + self.assertEqual(new_mo.picking_type_id, self.op_type_2) + new_mo.save() + # Kept after save: + self.assertEqual(new_mo.picking_type_id, self.op_type_2) + + def test_02_create_mo_change_op_type_manually(self): + new_mo = Form(self.env["mrp.production"]) + new_mo.product_id = self.product_2 + self.assertEqual(new_mo.picking_type_id, self.op_type_2) + new_mo.picking_type_id = self.standard_manuf_op_type + self.assertEqual(new_mo.picking_type_id, self.standard_manuf_op_type) + new_mo.save() + # Kept after save: + self.assertEqual(new_mo.picking_type_id, self.standard_manuf_op_type) diff --git a/setup/mrp_production_picking_type_from_route/odoo/addons/mrp_production_picking_type_from_route b/setup/mrp_production_picking_type_from_route/odoo/addons/mrp_production_picking_type_from_route new file mode 120000 index 000000000..4a471a160 --- /dev/null +++ b/setup/mrp_production_picking_type_from_route/odoo/addons/mrp_production_picking_type_from_route @@ -0,0 +1 @@ +../../../../mrp_production_picking_type_from_route \ No newline at end of file diff --git a/setup/mrp_production_picking_type_from_route/setup.py b/setup/mrp_production_picking_type_from_route/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_production_picking_type_from_route/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)