diff --git a/setup/stock_picking_procure_method/odoo/addons/stock_picking_procure_method b/setup/stock_picking_procure_method/odoo/addons/stock_picking_procure_method new file mode 120000 index 000000000..1c33a9a7c --- /dev/null +++ b/setup/stock_picking_procure_method/odoo/addons/stock_picking_procure_method @@ -0,0 +1 @@ +../../../../stock_picking_procure_method \ No newline at end of file diff --git a/setup/stock_picking_procure_method/setup.py b/setup/stock_picking_procure_method/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_picking_procure_method/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_picking_procure_method/README.rst b/stock_picking_procure_method/README.rst new file mode 100644 index 000000000..85e9b352b --- /dev/null +++ b/stock_picking_procure_method/README.rst @@ -0,0 +1,144 @@ +============================ +Stock Picking Procure Method +============================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fstock--logistics--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_picking_procure_method + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_picking_procure_method + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the possibility to set the supply method to *Apply Procurement +Rules* in the pickings, which is normally set to *Take From Stock* by default. + +This way, you can configure MTO flows triggered from the picking itself. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +This module is useless without either Odoo's `mrp` or `purchase` modules (or +both). Depending on your needs you should install them in advance. + +Configuration +============= + +This is an example scenario with two warehouses. WH2 will be allways supplied +through WH1. + +Common steps to `mrp` and `purchase` procurements: + +#. Go to *Inventory > Configuration > Settings > Warehouse* and set *Multi-Step + Routes* on. +#. Go to *Inventory > Configuration > Warehouse Management > Warehouses* +#. Create **WH1** with either *Manufacture to Resupply* or *Buy to + Resupply* this warehouse or both set. +#. Create **WH2** setting off *Manufacture to Resupply* and *Buy to + Resupply*. Set **WH1** as the *Resupply Warehouse*. +#. Go to *Inventory > Configuration > Warehouse Management > Routes* and click + on the *Make To Order* one. +#. Add a new *Procurement Rule* with these settings and save: + + - Name: *WH1 -> WH2-MTO* + - Action: *Pull From* + - Operation Type: *WH1: Internal Transfers* + - Source Location: *WH1/Stock* + - Destination Location: *WH2/Stock* + - Move Supply Method: *Take From Stock* + - Propagation of Procurement Group: *Propagate* + - Propagate cancel and split: `True` + - Warehouse to Propagate: *WH1* + +Now, if you want to trigger a manufacture: + + - Create a stockable product with a BoM list. + - In the product's *Inventory > Routes section* set *Make To Order* and + *Manufacture* on. + +Or if you want to trigger a purchase: + + - Create a stockable product with a vendor. + - In the product's *Inventory > Routes section* set *Make To Order* and + *Purchase* on. + +Usage +===== + +After configuring you procurement rules and your product routes: + +#. Go to *Inventory > Dashboard* and click on the *more options* icon (☰). +#. Choose *New > Planned Transfer*. +#. Set an origin and destination that is considered in the routes procurement + rules. +#. Set *Supply Method* to *Apply Procurement Rules*. +#. Set the products and quantities you want to supply. +#. Save and click on *Mark as To Do*. +#. Depending on the product's supply type a new MO or a new PO should be + created. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * David Vidal + * Pedro M. Baeza + * César A. Sánchez + +* Kitti Upariphutthiphong + +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/stock-logistics-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_picking_procure_method/__init__.py b/stock_picking_procure_method/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_picking_procure_method/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_picking_procure_method/__manifest__.py b/stock_picking_procure_method/__manifest__.py new file mode 100644 index 000000000..92d7209c7 --- /dev/null +++ b/stock_picking_procure_method/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2018 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Stock Picking Procure Method", + "summary": "Allows to force the procurement method from the picking", + "version": "16.0.0.0.0", + "category": "Warehouse", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "license": "AGPL-3", + "depends": ["stock"], + "data": ["views/stock_picking_views.xml"], + "installable": True, +} diff --git a/stock_picking_procure_method/i18n/pt_BR.po b/stock_picking_procure_method/i18n/pt_BR.po new file mode 100644 index 000000000..10255d26e --- /dev/null +++ b/stock_picking_procure_method/i18n/pt_BR.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_procure_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: pt_BR\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" + +#. module: stock_picking_procure_method +#: model:ir.model.fields,help:stock_picking_procure_method.field_stock_picking__procure_method +msgid "" +"By default, the system will take from the stock in the source location and " +"passively wait for availability. The other possibility allows you to " +"directly create a procurement on the source location (and thus ignore its " +"current stock) to gather products. If we want to chain moves and have this " +"one to wait for the previous, this second option should be chosen." +msgstr "" + +#. module: stock_picking_procure_method +#: model:ir.model.fields,field_description:stock_picking_procure_method.field_stock_picking__procure_method +msgid "Supply Method" +msgstr "" + +#. module: stock_picking_procure_method +#: model:ir.model,name:stock_picking_procure_method.model_stock_picking +msgid "Transfer" +msgstr "" diff --git a/stock_picking_procure_method/i18n/stock_picking_procure_method.pot b/stock_picking_procure_method/i18n/stock_picking_procure_method.pot new file mode 100644 index 000000000..e2eac021d --- /dev/null +++ b/stock_picking_procure_method/i18n/stock_picking_procure_method.pot @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_procure_method +# +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: stock_picking_procure_method +#: model:ir.model.fields,help:stock_picking_procure_method.field_stock_picking__procure_method +msgid "" +"By default, the system will take from the stock in the source location and " +"passively wait for availability. The other possibility allows you to " +"directly create a procurement on the source location (and thus ignore its " +"current stock) to gather products. If we want to chain moves and have this " +"one to wait for the previous, this second option should be chosen." +msgstr "" + +#. module: stock_picking_procure_method +#: model:ir.model.fields,field_description:stock_picking_procure_method.field_stock_picking__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_picking_procure_method +#: model:ir.model.fields,field_description:stock_picking_procure_method.field_stock_picking__id +msgid "ID" +msgstr "" + +#. module: stock_picking_procure_method +#: model:ir.model.fields,field_description:stock_picking_procure_method.field_stock_picking____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_picking_procure_method +#: model:ir.model.fields,field_description:stock_picking_procure_method.field_stock_picking__procure_method +msgid "Supply Method" +msgstr "" + +#. module: stock_picking_procure_method +#: model:ir.model,name:stock_picking_procure_method.model_stock_picking +msgid "Transfer" +msgstr "" diff --git a/stock_picking_procure_method/i18n/zh_CN.po b/stock_picking_procure_method/i18n/zh_CN.po new file mode 100644 index 000000000..db82673d3 --- /dev/null +++ b/stock_picking_procure_method/i18n/zh_CN.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_procure_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-10-12 16:36+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 3.8\n" + +#. module: stock_picking_procure_method +#: model:ir.model.fields,help:stock_picking_procure_method.field_stock_picking__procure_method +msgid "" +"By default, the system will take from the stock in the source location and " +"passively wait for availability. The other possibility allows you to " +"directly create a procurement on the source location (and thus ignore its " +"current stock) to gather products. If we want to chain moves and have this " +"one to wait for the previous, this second option should be chosen." +msgstr "" +"默认情况下,系统将从源位置中的库存中取出,并被动地等待可用性。另一种可能性使" +"您可以直接在源位置创建采购(从而忽略其当前库存)以收集产品。如果我们要链接移" +"动并让其等待上一个,则应选择第二个选项。" + +#. module: stock_picking_procure_method +#: model:ir.model.fields,field_description:stock_picking_procure_method.field_stock_picking__procure_method +msgid "Supply Method" +msgstr "供应方法" + +#. module: stock_picking_procure_method +#: model:ir.model,name:stock_picking_procure_method.model_stock_picking +msgid "Transfer" +msgstr "调拨" diff --git a/stock_picking_procure_method/models/__init__.py b/stock_picking_procure_method/models/__init__.py new file mode 100644 index 000000000..ae4c27227 --- /dev/null +++ b/stock_picking_procure_method/models/__init__.py @@ -0,0 +1 @@ +from . import stock_picking diff --git a/stock_picking_procure_method/models/stock_picking.py b/stock_picking_procure_method/models/stock_picking.py new file mode 100644 index 000000000..8456cab41 --- /dev/null +++ b/stock_picking_procure_method/models/stock_picking.py @@ -0,0 +1,44 @@ +# Copyright 2018 Tecnativa - David Vidal +# Copyright 2018 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + procure_method = fields.Selection( + selection="_selection_procure_method", + compute="_compute_procure_method", + inverse="_inverse_procure_method", + string="Supply Method", + help="By default, the system will take from the stock in the source " + "location and passively wait for availability. The other " + "possibility allows you to directly create a procurement on the " + "source location (and thus ignore its current stock) to gather " + "products. If we want to chain moves and have this one to wait " + "for the previous, this second option should be chosen.", + ) + + def _selection_procure_method(self): + return self.env["stock.move"].fields_get(allfields=["procure_method"])[ + "procure_method" + ]["selection"] + + @api.depends("move_ids.procure_method") + def _compute_procure_method(self): + for picking in self: + procure_method = False + for move in picking.move_ids: + if not procure_method: + procure_method = move.procure_method + elif procure_method != move.procure_method: + procure_method = False + break + picking.procure_method = procure_method + + def _inverse_procure_method(self): + self.filtered("procure_method").mapped("move_ids").update( + {"procure_method": self.procure_method} + ) diff --git a/stock_picking_procure_method/readme/CONFIGURE.rst b/stock_picking_procure_method/readme/CONFIGURE.rst new file mode 100644 index 000000000..dddbd935d --- /dev/null +++ b/stock_picking_procure_method/readme/CONFIGURE.rst @@ -0,0 +1,37 @@ +This is an example scenario with two warehouses. WH2 will be allways supplied +through WH1. + +Common steps to `mrp` and `purchase` procurements: + +#. Go to *Inventory > Configuration > Settings > Warehouse* and set *Multi-Step + Routes* on. +#. Go to *Inventory > Configuration > Warehouse Management > Warehouses* +#. Create **WH1** with either *Manufacture to Resupply* or *Buy to + Resupply* this warehouse or both set. +#. Create **WH2** setting off *Manufacture to Resupply* and *Buy to + Resupply*. Set **WH1** as the *Resupply Warehouse*. +#. Go to *Inventory > Configuration > Warehouse Management > Routes* and click + on the *Make To Order* one. +#. Add a new *Procurement Rule* with these settings and save: + + - Name: *WH1 -> WH2-MTO* + - Action: *Pull From* + - Operation Type: *WH1: Internal Transfers* + - Source Location: *WH1/Stock* + - Destination Location: *WH2/Stock* + - Move Supply Method: *Take From Stock* + - Propagation of Procurement Group: *Propagate* + - Propagate cancel and split: `True` + - Warehouse to Propagate: *WH1* + +Now, if you want to trigger a manufacture: + + - Create a stockable product with a BoM list. + - In the product's *Inventory > Routes section* set *Make To Order* and + *Manufacture* on. + +Or if you want to trigger a purchase: + + - Create a stockable product with a vendor. + - In the product's *Inventory > Routes section* set *Make To Order* and + *Purchase* on. diff --git a/stock_picking_procure_method/readme/CONTRIBUTORS.rst b/stock_picking_procure_method/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..a0a9fd0d0 --- /dev/null +++ b/stock_picking_procure_method/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* `Tecnativa `_: + + * David Vidal + * Pedro M. Baeza + * César A. Sánchez + +* Kitti Upariphutthiphong diff --git a/stock_picking_procure_method/readme/DESCRIPTION.rst b/stock_picking_procure_method/readme/DESCRIPTION.rst new file mode 100644 index 000000000..f942da3fa --- /dev/null +++ b/stock_picking_procure_method/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module adds the possibility to set the supply method to *Apply Procurement +Rules* in the pickings, which is normally set to *Take From Stock* by default. + +This way, you can configure MTO flows triggered from the picking itself. diff --git a/stock_picking_procure_method/readme/INSTALL.rst b/stock_picking_procure_method/readme/INSTALL.rst new file mode 100644 index 000000000..e0f898ffa --- /dev/null +++ b/stock_picking_procure_method/readme/INSTALL.rst @@ -0,0 +1,2 @@ +This module is useless without either Odoo's `mrp` or `purchase` modules (or +both). Depending on your needs you should install them in advance. diff --git a/stock_picking_procure_method/readme/USAGE.rst b/stock_picking_procure_method/readme/USAGE.rst new file mode 100644 index 000000000..046740b8e --- /dev/null +++ b/stock_picking_procure_method/readme/USAGE.rst @@ -0,0 +1,11 @@ +After configuring you procurement rules and your product routes: + +#. Go to *Inventory > Dashboard* and click on the *more options* icon (☰). +#. Choose *New > Planned Transfer*. +#. Set an origin and destination that is considered in the routes procurement + rules. +#. Set *Supply Method* to *Apply Procurement Rules*. +#. Set the products and quantities you want to supply. +#. Save and click on *Mark as To Do*. +#. Depending on the product's supply type a new MO or a new PO should be + created. diff --git a/stock_picking_procure_method/static/description/icon.png b/stock_picking_procure_method/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_picking_procure_method/static/description/icon.png differ diff --git a/stock_picking_procure_method/static/description/index.html b/stock_picking_procure_method/static/description/index.html new file mode 100644 index 000000000..334c5ad59 --- /dev/null +++ b/stock_picking_procure_method/static/description/index.html @@ -0,0 +1,499 @@ + + + + + + +Stock Picking Procure Method + + + +
+

Stock Picking Procure Method

+ + +

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

This module adds the possibility to set the supply method to Apply Procurement +Rules in the pickings, which is normally set to Take From Stock by default.

+

This way, you can configure MTO flows triggered from the picking itself.

+

Table of contents

+ +
+

Installation

+

This module is useless without either Odoo’s mrp or purchase modules (or +both). Depending on your needs you should install them in advance.

+
+
+

Configuration

+

This is an example scenario with two warehouses. WH2 will be allways supplied +through WH1.

+

Common steps to mrp and purchase procurements:

+
    +
  1. Go to Inventory > Configuration > Settings > Warehouse and set Multi-Step +Routes on.
  2. +
  3. Go to Inventory > Configuration > Warehouse Management > Warehouses
  4. +
  5. Create WH1 with either Manufacture to Resupply or Buy to +Resupply this warehouse or both set.
  6. +
  7. Create WH2 setting off Manufacture to Resupply and Buy to +Resupply. Set WH1 as the Resupply Warehouse.
  8. +
  9. Go to Inventory > Configuration > Warehouse Management > Routes and click +on the Make To Order one.
  10. +
  11. Add a new Procurement Rule with these settings and save:
      +
    • Name: WH1 -> WH2-MTO
    • +
    • Action: Pull From
    • +
    • Operation Type: WH1: Internal Transfers
    • +
    • Source Location: WH1/Stock
    • +
    • Destination Location: WH2/Stock
    • +
    • Move Supply Method: Take From Stock
    • +
    • Propagation of Procurement Group: Propagate
    • +
    • Propagate cancel and split: True
    • +
    • Warehouse to Propagate: WH1
    • +
    +
  12. +
+

Now, if you want to trigger a manufacture:

+
+
    +
  • Create a stockable product with a BoM list.
  • +
  • In the product’s Inventory > Routes section set Make To Order and +Manufacture on.
  • +
+
+

Or if you want to trigger a purchase:

+
+
    +
  • Create a stockable product with a vendor.
  • +
  • In the product’s Inventory > Routes section set Make To Order and +Purchase on.
  • +
+
+
+
+

Usage

+

After configuring you procurement rules and your product routes:

+
    +
  1. Go to Inventory > Dashboard and click on the more options icon (☰).
  2. +
  3. Choose New > Planned Transfer.
  4. +
  5. Set an origin and destination that is considered in the routes procurement +rules.
  6. +
  7. Set Supply Method to Apply Procurement Rules.
  8. +
  9. Set the products and quantities you want to supply.
  10. +
  11. Save and click on Mark as To Do.
  12. +
  13. Depending on the product’s supply type a new MO or a new PO should be +created.
  14. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

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/stock-logistics-warehouse project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_picking_procure_method/tests/__init__.py b/stock_picking_procure_method/tests/__init__.py new file mode 100644 index 000000000..f134401c6 --- /dev/null +++ b/stock_picking_procure_method/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_picking_procure_method diff --git a/stock_picking_procure_method/tests/test_stock_picking_procure_method.py b/stock_picking_procure_method/tests/test_stock_picking_procure_method.py new file mode 100644 index 000000000..03579070f --- /dev/null +++ b/stock_picking_procure_method/tests/test_stock_picking_procure_method.py @@ -0,0 +1,76 @@ +# Copyright 2018 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestStockPickingMTO(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestStockPickingMTO, cls).setUpClass() + cls.mto_route = cls.env.ref("stock.route_warehouse0_mto") + cls.product = cls.env["product.product"].create( + { + "name": "Test MTO Product", + "route_ids": [(6, 0, cls.mto_route.ids)], + "type": "product", + } + ) + cls.wh_obj = cls.env["stock.warehouse"] + cls.wh1 = cls.wh_obj.create({"name": "Test WH1", "code": "TSWH1"}) + cls.wh2 = cls.wh_obj.create( + { + "name": "Test WH2", + "code": "TSWH2", + "resupply_wh_ids": [(6, 0, cls.wh1.ids)], + } + ) + cls.procurement_rule = cls.env["stock.rule"].create( + { + "name": "TST-WH1 -> TST-WH2 MTO", + "route_id": cls.mto_route.id, + "action": "pull", + "location_src_id": cls.wh1.lot_stock_id.id, + "procure_method": "make_to_stock", + "picking_type_id": cls.wh1.int_type_id.id, + "location_dest_id": cls.wh2.lot_stock_id.id, + "warehouse_id": cls.wh2.id, + "group_propagation_option": "propagate", + "propagate_cancel": True, + "propagate_warehouse_id": cls.wh1.id, + } + ) + cls.picking_obj = cls.env["stock.picking"].with_context(planned_picking=True) + cls.picking = cls.picking_obj.create( + { + "picking_type_id": cls.wh1.int_type_id.id, + "location_id": cls.wh1.lot_stock_id.id, + "location_dest_id": cls.wh2.lot_stock_id.id, + } + ) + + def test_compute_procure_method(self): + # No moves + self.assertFalse(self.picking.procure_method) + # A new move defaults to MTS + move_line = self.env["stock.move"].create( + { + "name": "TSTMOVE001", + "picking_id": self.picking.id, + "product_id": self.product.id, + "product_uom": self.product.uom_id.id, + "product_uom_qty": 100, + "location_id": self.wh1.lot_stock_id.id, + "location_dest_id": self.wh2.lot_stock_id.id, + } + ) + self.assertEqual(self.picking.procure_method, "make_to_stock") + # Change move procure method to MTO + move_line.procure_method = "make_to_order" + self.assertEqual(self.picking.procure_method, "make_to_order") + # Add a new line with MTS rule + move_line.copy({"procure_method": "make_to_stock"}) + self.assertFalse(self.picking.procure_method) + # We set the procure method in the picking + self.picking.procure_method = "make_to_order" + self.assertEqual(self.picking.move_ids[1].procure_method, "make_to_order") diff --git a/stock_picking_procure_method/views/stock_picking_views.xml b/stock_picking_procure_method/views/stock_picking_views.xml new file mode 100644 index 000000000..fc5063935 --- /dev/null +++ b/stock_picking_procure_method/views/stock_picking_views.xml @@ -0,0 +1,16 @@ + + + + stock.picking + + + + + + + +