diff --git a/mrp_stock_orderpoint_manual_procurement/README.rst b/mrp_stock_orderpoint_manual_procurement/README.rst new file mode 100644 index 000000000..afd5839d4 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/README.rst @@ -0,0 +1,83 @@ +======================================= +MRP Stock Orderpoint Manual Procurement +======================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/13.0/mrp_stock_orderpoint_manual_procurement + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-mrp_stock_orderpoint_manual_procurement + :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/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module updates a new field *Requested by* in Manufacturing Orders +in the case the MO has been created as a result of a manual procurement from +an orderpoint. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Go to an orderpoint and do a manual procurement for a manufactured product. +Your user will be set as *Requeste by* in the newly created MO. + +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 +~~~~~~~ + +* Forgeflow + +Contributors +~~~~~~~~~~~~ + +* Adria Gil Sorribes +* Lois Rilo Antelo +* Pimolnat Suntian + +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_stock_orderpoint_manual_procurement/__init__.py b/mrp_stock_orderpoint_manual_procurement/__init__.py new file mode 100644 index 000000000..31660d6a9 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/mrp_stock_orderpoint_manual_procurement/__manifest__.py b/mrp_stock_orderpoint_manual_procurement/__manifest__.py new file mode 100644 index 000000000..2b25f53e3 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2018-20 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "MRP Stock Orderpoint Manual Procurement", + "summary": "Updates the value of MO Responsible and keeps track" + "of changes regarding this field", + "version": "13.0.1.0.0", + "author": "Forgeflow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "category": "Manufacturing", + "depends": ["mrp", "stock_orderpoint_manual_procurement"], + "data": ["views/mrp_production_view.xml"], + "license": "AGPL-3", + "installable": True, + "application": False, + "auto_install": True, +} diff --git a/mrp_stock_orderpoint_manual_procurement/i18n/mrp_stock_orderpoint_manual_procurement.pot b/mrp_stock_orderpoint_manual_procurement/i18n/mrp_stock_orderpoint_manual_procurement.pot new file mode 100644 index 000000000..fd9525633 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/i18n/mrp_stock_orderpoint_manual_procurement.pot @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_stock_orderpoint_manual_procurement +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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_stock_orderpoint_manual_procurement +#: model:ir.model,name:mrp_stock_orderpoint_manual_procurement.model_mrp_production +msgid "Production Order" +msgstr "" + +#. module: mrp_stock_orderpoint_manual_procurement +#: model:ir.model.fields,field_description:mrp_stock_orderpoint_manual_procurement.field_mrp_production__requested_by +msgid "Requested By" +msgstr "" + +#. module: mrp_stock_orderpoint_manual_procurement +#: model:ir.model,name:mrp_stock_orderpoint_manual_procurement.model_stock_rule +msgid "Stock Rule" +msgstr "" + diff --git a/mrp_stock_orderpoint_manual_procurement/models/__init__.py b/mrp_stock_orderpoint_manual_procurement/models/__init__.py new file mode 100644 index 000000000..4c76d6030 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import mrp_production +from . import stock_rule diff --git a/mrp_stock_orderpoint_manual_procurement/models/mrp_production.py b/mrp_stock_orderpoint_manual_procurement/models/mrp_production.py new file mode 100644 index 000000000..7904da876 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/models/mrp_production.py @@ -0,0 +1,10 @@ +# Copyright 2019-20 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class MrpProduction(models.Model): + _inherit = "mrp.production" + + requested_by = fields.Many2one(comodel_name="res.users", track_visibility="always") diff --git a/mrp_stock_orderpoint_manual_procurement/models/stock_rule.py b/mrp_stock_orderpoint_manual_procurement/models/stock_rule.py new file mode 100644 index 000000000..6ffc8657a --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/models/stock_rule.py @@ -0,0 +1,36 @@ +# Copyright 2019-20 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +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, + ): + res = super(StockRule, self)._prepare_mo_vals( + product_id, + product_qty, + product_uom, + location_id, + name, + origin, + company_id, + values, + bom, + ) + requested_uid = self.env.context.get("requested_uid") + if requested_uid: + res.update({"requested_by": requested_uid.id}) + return res diff --git a/mrp_stock_orderpoint_manual_procurement/readme/CONTRIBUTORS.rst b/mrp_stock_orderpoint_manual_procurement/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..900752be9 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Adria Gil Sorribes +* Lois Rilo Antelo +* Pimolnat Suntian diff --git a/mrp_stock_orderpoint_manual_procurement/readme/DESCRIPTION.rst b/mrp_stock_orderpoint_manual_procurement/readme/DESCRIPTION.rst new file mode 100644 index 000000000..7c75978f8 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module updates a new field *Requested by* in Manufacturing Orders +in the case the MO has been created as a result of a manual procurement from +an orderpoint. diff --git a/mrp_stock_orderpoint_manual_procurement/readme/USAGE.rst b/mrp_stock_orderpoint_manual_procurement/readme/USAGE.rst new file mode 100644 index 000000000..4fb2af6a2 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/readme/USAGE.rst @@ -0,0 +1,2 @@ +Go to an orderpoint and do a manual procurement for a manufactured product. +Your user will be set as *Requeste by* in the newly created MO. diff --git a/mrp_stock_orderpoint_manual_procurement/static/description/icon.png b/mrp_stock_orderpoint_manual_procurement/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mrp_stock_orderpoint_manual_procurement/static/description/icon.png differ diff --git a/mrp_stock_orderpoint_manual_procurement/static/description/index.html b/mrp_stock_orderpoint_manual_procurement/static/description/index.html new file mode 100644 index 000000000..3366536be --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +MRP Stock Orderpoint Manual Procurement + + + +
+

MRP Stock Orderpoint Manual Procurement

+ + +

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

+

This module updates a new field Requested by in Manufacturing Orders +in the case the MO has been created as a result of a manual procurement from +an orderpoint.

+

Table of contents

+ +
+

Usage

+

Go to an orderpoint and do a manual procurement for a manufactured product. +Your user will be set as Requeste by in the newly created MO.

+
+
+

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

+
    +
  • Forgeflow
  • +
+
+
+

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_stock_orderpoint_manual_procurement/tests/__init__.py b/mrp_stock_orderpoint_manual_procurement/tests/__init__.py new file mode 100644 index 000000000..bd140c66d --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_mrp_manual_procurement diff --git a/mrp_stock_orderpoint_manual_procurement/tests/test_mrp_manual_procurement.py b/mrp_stock_orderpoint_manual_procurement/tests/test_mrp_manual_procurement.py new file mode 100644 index 000000000..18925b4d6 --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/tests/test_mrp_manual_procurement.py @@ -0,0 +1,129 @@ +# Copyright 2019-20 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestMrpManualProcurement(TransactionCase): + def setUp(self): + super(TestMrpManualProcurement, self).setUp() + + self.production_model = self.env["mrp.production"] + self.product_model = self.env["product.product"] + self.orderpoint_model = self.env["stock.warehouse.orderpoint"] + self.loc_model = self.env["stock.location"] + self.route_model = self.env["stock.location.route"] + self.manual_procurement_wiz = self.env["make.procurement.orderpoint"] + self.bom_model = self.env["mrp.bom"] + self.boml_model = self.env["mrp.bom.line"] + + self.warehouse = self.env.ref("stock.warehouse0") + self.stock_loc = self.env.ref("stock.stock_location_stock") + route_manuf = self.env.ref("mrp.route_warehouse0_manufacture") + + # Create a new location and route: + self.secondary_loc = self.loc_model.create( + { + "name": "Test location", + "usage": "internal", + "location_id": self.warehouse.view_location_id.id, + } + ) + test_route = self.route_model.create( + { + "name": "Stock -> Test", + "product_selectable": True, + "rule_ids": [ + ( + 0, + 0, + { + "name": "stock to test", + "action": "pull", + "location_id": self.secondary_loc.id, + "location_src_id": self.stock_loc.id, + "procure_method": "make_to_order", + "picking_type_id": self.env.ref( + "stock.picking_type_internal" + ).id, + }, + ) + ], + } + ) + + # Prepare Products: + routes = route_manuf + test_route + self.product = self.product_model.create( + {"name": "Test Product", "route_ids": [(6, 0, routes.ids)]} + ) + component = self.product_model.create({"name": "Test component"}) + + # Create Bill of Materials: + self.bom_1 = self.bom_model.create( + { + "product_id": self.product.id, + "product_tmpl_id": self.product.product_tmpl_id.id, + "product_uom_id": self.product.uom_id.id, + "product_qty": 1.0, + } + ) + self.boml_model.create( + {"bom_id": self.bom_1.id, "product_id": component.id, "product_qty": 1.0} + ) + + # Create Orderpoint: + self.orderpoint_stock = self.orderpoint_model.create( + { + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "product_id": self.product.id, + "product_min_qty": 10.0, + "product_max_qty": 50.0, + "product_uom": self.product.uom_id.id, + } + ) + self.orderpoint_secondary_loc = self.orderpoint_model.create( + { + "warehouse_id": self.warehouse.id, + "location_id": self.secondary_loc.id, + "product_id": self.product.id, + "product_min_qty": 10.0, + "product_max_qty": 20.0, + "product_uom": self.product.uom_id.id, + } + ) + + # Create User: + self.test_user = self.env["res.users"].create({"name": "John", "login": "test"}) + + def manual_procurement(self, orderpoint, user): + """Make Procurement from Reordering Rule""" + context = { + "active_model": "stock.warehouse.orderpoint", + "active_ids": orderpoint.ids, + "active_id": orderpoint.id, + } + wizard = ( + self.manual_procurement_wiz.with_user(user).with_context(context).create({}) + ) + wizard.make_procurement() + return wizard + + def test_01_manual_procurement_requested_by(self): + """Tests manual procurement fills requested_by field. + Direct MO creation.""" + self.manual_procurement(self.orderpoint_stock, self.test_user) + mo = self.production_model.search([("requested_by", "=", self.test_user.id)]) + self.assertTrue(mo) + self.assertEqual(mo.product_id, self.product) + self.assertEqual(mo.product_qty, 50.0) + + def test_02_manual_procurement_requested_by_indirect(self): + """Tests manual procurement fills requested_by field. + Indirect MO creation (transfer -> MO).""" + self.manual_procurement(self.orderpoint_secondary_loc, self.test_user) + mo = self.production_model.search([("requested_by", "=", self.test_user.id)]) + self.assertTrue(mo) + self.assertEqual(mo.product_id, self.product) + self.assertEqual(mo.product_qty, 20.0) diff --git a/mrp_stock_orderpoint_manual_procurement/views/mrp_production_view.xml b/mrp_stock_orderpoint_manual_procurement/views/mrp_production_view.xml new file mode 100644 index 000000000..b43c5d2de --- /dev/null +++ b/mrp_stock_orderpoint_manual_procurement/views/mrp_production_view.xml @@ -0,0 +1,17 @@ + + + + + mrp.production.form - mrp_stock_orderpoint_manual_procurement + mrp.production + + + + + + + + diff --git a/setup/mrp_stock_orderpoint_manual_procurement/odoo/addons/mrp_stock_orderpoint_manual_procurement b/setup/mrp_stock_orderpoint_manual_procurement/odoo/addons/mrp_stock_orderpoint_manual_procurement new file mode 120000 index 000000000..5bdb38682 --- /dev/null +++ b/setup/mrp_stock_orderpoint_manual_procurement/odoo/addons/mrp_stock_orderpoint_manual_procurement @@ -0,0 +1 @@ +../../../../mrp_stock_orderpoint_manual_procurement \ No newline at end of file diff --git a/setup/mrp_stock_orderpoint_manual_procurement/setup.py b/setup/mrp_stock_orderpoint_manual_procurement/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mrp_stock_orderpoint_manual_procurement/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)