diff --git a/mrp_restrict_lot/README.rst b/mrp_restrict_lot/README.rst new file mode 100644 index 000000000..e7a2b6311 --- /dev/null +++ b/mrp_restrict_lot/README.rst @@ -0,0 +1,91 @@ +================ +MRP Restrict Lot +================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/14.0/mrp_restrict_lot + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_restrict_lot + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/129/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Propagate a specific lot to the Manufacturing Order (on the final product) + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Typically used with module sale_order_lot_generator. +- Create a sale order for a product to produce and configured with automatic lot generation. +- Confirm the sale order +The lot will be affected to the created manufacturing order + +Other module than sale_order_lot_generator could implement other uses cases for this module + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Florian da Costa + +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-florian-dacosta| image:: https://github.com/florian-dacosta.png?size=40px + :target: https://github.com/florian-dacosta + :alt: florian-dacosta + +Current `maintainer `__: + +|maintainer-florian-dacosta| + +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_restrict_lot/__init__.py b/mrp_restrict_lot/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mrp_restrict_lot/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_restrict_lot/__manifest__.py b/mrp_restrict_lot/__manifest__.py new file mode 100644 index 000000000..a58e4597c --- /dev/null +++ b/mrp_restrict_lot/__manifest__.py @@ -0,0 +1,17 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "MRP Restrict Lot", + "version": "14.0.1.0.0", + "category": "Manufacturing", + "author": "Akretion,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "license": "AGPL-3", + "maintainers": ["florian-dacosta"], + "development_status": "Beta", + "depends": [ + "stock_restrict_lot", + "mrp", + ], + "installable": True, +} diff --git a/mrp_restrict_lot/i18n/mrp_restrict_lot.pot b/mrp_restrict_lot/i18n/mrp_restrict_lot.pot new file mode 100644 index 000000000..619321a23 --- /dev/null +++ b/mrp_restrict_lot/i18n/mrp_restrict_lot.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_restrict_lot +# +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_restrict_lot +#: model:ir.model.fields,field_description:mrp_restrict_lot.field_stock_rule__display_name +msgid "Display Name" +msgstr "" + +#. module: mrp_restrict_lot +#: model:ir.model.fields,field_description:mrp_restrict_lot.field_stock_rule__id +msgid "ID" +msgstr "" + +#. module: mrp_restrict_lot +#: model:ir.model.fields,field_description:mrp_restrict_lot.field_stock_rule____last_update +msgid "Last Modified on" +msgstr "" + +#. module: mrp_restrict_lot +#: model:ir.model,name:mrp_restrict_lot.model_stock_rule +msgid "Stock Rule" +msgstr "" diff --git a/mrp_restrict_lot/models/__init__.py b/mrp_restrict_lot/models/__init__.py new file mode 100644 index 000000000..55eae1720 --- /dev/null +++ b/mrp_restrict_lot/models/__init__.py @@ -0,0 +1 @@ +from . import stock_rule diff --git a/mrp_restrict_lot/models/stock_rule.py b/mrp_restrict_lot/models/stock_rule.py new file mode 100644 index 000000000..d92d9ad77 --- /dev/null +++ b/mrp_restrict_lot/models/stock_rule.py @@ -0,0 +1,37 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class StockRule(models.Model): + _inherit = "stock.rule" + + def _prepare_mo_vals( + self, + product_id, + product_qty, + product_uom, + location_id, + name, + origin, + company_id, + values, + bom, + ): + vals = super()._prepare_mo_vals( + product_id, + product_qty, + product_uom, + location_id, + name, + origin, + company_id, + values, + bom, + ) + lot_id = values.get("restrict_lot_id") + if lot_id: + vals["lot_producing_id"] = lot_id + lot = self.env["stock.production.lot"].browse(lot_id) + vals["name"] = lot.name + return vals diff --git a/mrp_restrict_lot/readme/CONTRIBUTORS.rst b/mrp_restrict_lot/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..0bddb053a --- /dev/null +++ b/mrp_restrict_lot/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Florian da Costa diff --git a/mrp_restrict_lot/readme/DESCRIPTION.rst b/mrp_restrict_lot/readme/DESCRIPTION.rst new file mode 100644 index 000000000..4ce98a6c0 --- /dev/null +++ b/mrp_restrict_lot/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Propagate a specific lot to the Manufacturing Order (on the final product) diff --git a/mrp_restrict_lot/readme/USAGE.rst b/mrp_restrict_lot/readme/USAGE.rst new file mode 100644 index 000000000..74df36fdb --- /dev/null +++ b/mrp_restrict_lot/readme/USAGE.rst @@ -0,0 +1,6 @@ +Typically used with module sale_order_lot_generator. +- Create a sale order for a product to produce and configured with automatic lot generation. +- Confirm the sale order +The lot will be affected to the created manufacturing order + +Other module than sale_order_lot_generator could implement other uses cases for this module diff --git a/mrp_restrict_lot/static/description/icon.png b/mrp_restrict_lot/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mrp_restrict_lot/static/description/icon.png differ diff --git a/mrp_restrict_lot/static/description/index.html b/mrp_restrict_lot/static/description/index.html new file mode 100644 index 000000000..5d6c3e705 --- /dev/null +++ b/mrp_restrict_lot/static/description/index.html @@ -0,0 +1,430 @@ + + + + + + +MRP Restrict Lot + + + +
+

MRP Restrict Lot

+ + +

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

+

Propagate a specific lot to the Manufacturing Order (on the final product)

+

Table of contents

+ +
+

Usage

+

Typically used with module sale_order_lot_generator. +- Create a sale order for a product to produce and configured with automatic lot generation. +- Confirm the sale order +The lot will be affected to the created manufacturing order

+

Other module than sale_order_lot_generator could implement other uses cases for this module

+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

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.

+

Current maintainer:

+

florian-dacosta

+

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_restrict_lot/tests/__init__.py b/mrp_restrict_lot/tests/__init__.py new file mode 100644 index 000000000..73b7135b6 --- /dev/null +++ b/mrp_restrict_lot/tests/__init__.py @@ -0,0 +1 @@ +from . import test_manufaturing_lot diff --git a/mrp_restrict_lot/tests/test_manufaturing_lot.py b/mrp_restrict_lot/tests/test_manufaturing_lot.py new file mode 100644 index 000000000..17f18170b --- /dev/null +++ b/mrp_restrict_lot/tests/test_manufaturing_lot.py @@ -0,0 +1,51 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import SavepointCase + + +class TestRestrictLot(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.customer_loc = cls.env.ref("stock.stock_location_customers") + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.panel_wood_prd = cls.env.ref("mrp.product_product_wood_panel") + manufacture_route = cls.env.ref("mrp.route_warehouse0_manufacture") + mto_route = cls.env.ref("stock.route_warehouse0_mto") + mto_route.write({"active": True}) + # ensure full make to order and not mts or mto + mto_route.rule_ids.write({"procure_method": "make_to_order"}) + cls.panel_wood_prd.write( + {"route_ids": [(4, manufacture_route.id, 0), (4, mto_route.id, 0)]} + ) + cls.out_picking_type = cls.env.ref("stock.picking_type_out") + + def test_manufacturing_lot(self): + lot = self.env["stock.production.lot"].create( + { + "name": "lot1", + "product_id": self.panel_wood_prd.id, + "company_id": self.warehouse.company_id.id, + } + ) + + group = self.env["procurement.group"].create({"name": "My test delivery"}) + move = self.env["stock.move"].create( + { + "product_id": self.panel_wood_prd.id, + "location_id": self.warehouse.lot_stock_id.id, + "location_dest_id": self.customer_loc.id, + "product_uom_qty": 1, + "product_uom": self.panel_wood_prd.uom_id.id, + "name": "test", + "procure_method": "make_to_order", + "warehouse_id": self.warehouse.id, + "restrict_lot_id": lot.id, + "picking_type_id": self.out_picking_type.id, + "group_id": group.id, + } + ) + move._action_confirm() + mo = move.move_orig_ids.production_id + self.assertEqual(mo.lot_producing_id.id, lot.id) + self.assertEqual(mo.name, lot.name)