diff --git a/setup/shopfloor_location_release_channel_restriction/odoo/addons/shopfloor_location_release_channel_restriction b/setup/shopfloor_location_release_channel_restriction/odoo/addons/shopfloor_location_release_channel_restriction new file mode 120000 index 00000000000..c4807f0b6bb --- /dev/null +++ b/setup/shopfloor_location_release_channel_restriction/odoo/addons/shopfloor_location_release_channel_restriction @@ -0,0 +1 @@ +../../../../shopfloor_location_release_channel_restriction \ No newline at end of file diff --git a/setup/shopfloor_location_release_channel_restriction/setup.py b/setup/shopfloor_location_release_channel_restriction/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/shopfloor_location_release_channel_restriction/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/shopfloor_location_release_channel_restriction/README.rst b/shopfloor_location_release_channel_restriction/README.rst new file mode 100644 index 00000000000..cc54eac9046 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/README.rst @@ -0,0 +1,106 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================================== +Shopfloor Location Release Channel Restirction +============================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:94ee0043f5542fb35caf079aa0c10385e7c4907038985ac0570744ceef82b740 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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%2Fwms-lightgray.png?logo=github + :target: https://github.com/OCA/wms/tree/16.0/shopfloor_location_release_channel_restriction + :alt: OCA/wms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_location_release_channel_restriction + :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/wms&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to benefit from +``stock_location_release_channel_restriction`` on shopfloor level. + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +As in shopfloor, we don't transfer immediately the movement after having +set the destination, we needed to find a way to restrict the location. + +The only way was to set the restriction when setting the destination +(which differs from the base module). + +We used also the ``is_dest_location_valid()`` function which is called +before setting the destination in order to return the error to the user. + +Configuration +============= + +- See ``stock_location_release_channel_restriction`` 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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Denis Roussel denis.roussel@acsone.eu + +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-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px + :target: https://github.com/rousseldenis + :alt: rousseldenis + +Current `maintainer `__: + +|maintainer-rousseldenis| + +This module is part of the `OCA/wms `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/shopfloor_location_release_channel_restriction/__init__.py b/shopfloor_location_release_channel_restriction/__init__.py new file mode 100644 index 00000000000..8f275c2963c --- /dev/null +++ b/shopfloor_location_release_channel_restriction/__init__.py @@ -0,0 +1,2 @@ +from . import services +from . import actions diff --git a/shopfloor_location_release_channel_restriction/__manifest__.py b/shopfloor_location_release_channel_restriction/__manifest__.py new file mode 100644 index 00000000000..18da9f3c93b --- /dev/null +++ b/shopfloor_location_release_channel_restriction/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2026 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Shopfloor Location Release Channel Restirction", + "summary": """This module allows to make the link between shopfloor behaviour and + the stock locations release channel restriction module""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "maintainers": ["rousseldenis"], + "website": "https://github.com/OCA/wms", + "depends": [ + "stock_location_release_channel_restriction", + "shopfloor", + ], +} diff --git a/shopfloor_location_release_channel_restriction/actions/__init__.py b/shopfloor_location_release_channel_restriction/actions/__init__.py new file mode 100644 index 00000000000..12bab770a38 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/actions/__init__.py @@ -0,0 +1 @@ +from . import stock diff --git a/shopfloor_location_release_channel_restriction/actions/stock.py b/shopfloor_location_release_channel_restriction/actions/stock.py new file mode 100644 index 00000000000..4eeb7e1f926 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/actions/stock.py @@ -0,0 +1,17 @@ +# Copyright 2026 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.addons.component.core import Component + + +class StockAction(Component): + """Provide methods to work with stock operations.""" + + _inherit = "shopfloor.stock.action" + + def _set_release_channel_restriction(self, lines): + lines._set_release_channel_current_restriction() + + def set_destination_on_lines(self, lines, location_dest): + res = super().set_destination_on_lines(lines, location_dest) + self._set_release_channel_restriction(lines) + return res diff --git a/shopfloor_location_release_channel_restriction/readme/CONFIGURE.md b/shopfloor_location_release_channel_restriction/readme/CONFIGURE.md new file mode 100644 index 00000000000..619d3bc22f2 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/readme/CONFIGURE.md @@ -0,0 +1 @@ +- See `stock_location_release_channel_restriction` module. diff --git a/shopfloor_location_release_channel_restriction/readme/CONTEXT.md b/shopfloor_location_release_channel_restriction/readme/CONTEXT.md new file mode 100644 index 00000000000..5cc9cf36e69 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/readme/CONTEXT.md @@ -0,0 +1,8 @@ +As in shopfloor, we don't transfer immediately the movement after having set +the destination, we needed to find a way to restrict the location. + +The only way was to set the restriction when setting the destination (which differs from +the base module). + +We used also the `is_dest_location_valid()` function which is called before setting the +destination in order to return the error to the user. diff --git a/shopfloor_location_release_channel_restriction/readme/CONTRIBUTORS.md b/shopfloor_location_release_channel_restriction/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..4e7e6847269 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Denis Roussel diff --git a/shopfloor_location_release_channel_restriction/readme/DESCRIPTION.md b/shopfloor_location_release_channel_restriction/readme/DESCRIPTION.md new file mode 100644 index 00000000000..269ceea5c51 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows to benefit from `stock_location_release_channel_restriction` on +shopfloor level. diff --git a/shopfloor_location_release_channel_restriction/services/__init__.py b/shopfloor_location_release_channel_restriction/services/__init__.py new file mode 100644 index 00000000000..f3b621e7109 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/services/__init__.py @@ -0,0 +1 @@ +from . import base_shopfloor diff --git a/shopfloor_location_release_channel_restriction/services/base_shopfloor.py b/shopfloor_location_release_channel_restriction/services/base_shopfloor.py new file mode 100644 index 00000000000..a2da49ecefd --- /dev/null +++ b/shopfloor_location_release_channel_restriction/services/base_shopfloor.py @@ -0,0 +1,20 @@ +# Copyright 2026 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.addons.component.core import AbstractComponent + + +class BaseShopfloorProcess(AbstractComponent): + _inherit = "base.shopfloor.process" + + def is_dest_location_valid(self, moves, location) -> bool: + """ + Check if the scanned location has release channel restriction + """ + res = super().is_dest_location_valid(moves, location) + + if any( + not move._valid_location_release_channel_restriction(location) + for move in moves.move_line_ids + ): + return False + return res diff --git a/shopfloor_location_release_channel_restriction/static/description/icon.png b/shopfloor_location_release_channel_restriction/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/shopfloor_location_release_channel_restriction/static/description/icon.png differ diff --git a/shopfloor_location_release_channel_restriction/static/description/index.html b/shopfloor_location_release_channel_restriction/static/description/index.html new file mode 100644 index 00000000000..4f7851088e6 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/static/description/index.html @@ -0,0 +1,449 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Shopfloor Location Release Channel Restirction

+ +

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

+

This module allows to benefit from +stock_location_release_channel_restriction on shopfloor level.

+

Table of contents

+ +
+

Use Cases / Context

+

As in shopfloor, we don’t transfer immediately the movement after having +set the destination, we needed to find a way to restrict the location.

+

The only way was to set the restriction when setting the destination +(which differs from the base module).

+

We used also the is_dest_location_valid() function which is called +before setting the destination in order to return the error to the user.

+
+
+

Configuration

+
    +
  • See stock_location_release_channel_restriction 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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

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:

+

rousseldenis

+

This module is part of the OCA/wms project on GitHub.

+

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

+
+
+
+
+ + diff --git a/shopfloor_location_release_channel_restriction/tests/__init__.py b/shopfloor_location_release_channel_restriction/tests/__init__.py new file mode 100644 index 00000000000..e82ebe699b9 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/tests/__init__.py @@ -0,0 +1 @@ +from . import test_location_release_restriction diff --git a/shopfloor_location_release_channel_restriction/tests/test_location_release_restriction.py b/shopfloor_location_release_channel_restriction/tests/test_location_release_restriction.py new file mode 100644 index 00000000000..f5c9c6f8399 --- /dev/null +++ b/shopfloor_location_release_channel_restriction/tests/test_location_release_restriction.py @@ -0,0 +1,199 @@ +# Copyright 2026 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.addons.shopfloor_base.tests.common import CommonCase + + +class TestStockLocation(CommonCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.StockLocation = cls.env["stock.location"] + + cls.menu = cls.env.ref( + "shopfloor.shopfloor_menu_demo_location_content_transfer" + ) + cls.profile = cls.env.ref("shopfloor_base.profile_demo_1") + cls.customers = cls.env.ref("stock.stock_location_customers") + cls.picking_type = cls.menu.sudo().picking_type_ids + cls.wh = cls.picking_type.warehouse_id + cls.wh.delivery_steps = "pick_ship" + cls.out = cls.wh.wh_output_stock_loc_id + cls.stock = cls.wh.lot_stock_id + cls.StockLocation = cls.StockLocation.sudo() + cls.move_obj = cls.env["stock.move"] + cls.StockLocation._parent_store_compute() + cls.loc_lvl = cls.wh.lot_stock_id + cls.loc_lvl_1 = cls.StockLocation.create( + {"name": "level_1", "location_id": cls.loc_lvl.id} + ) + cls.loc_lvl_1_1 = cls.StockLocation.create( + {"name": "level_1_1", "location_id": cls.loc_lvl_1.id} + ) + + cls.loc_lvl_1_1_1 = cls.StockLocation.create( + {"name": "level_1_1_1", "location_id": cls.loc_lvl_1_1.id} + ) + cls.loc_lvl_1_1_2 = cls.StockLocation.create( + {"name": "level_1_1_1", "location_id": cls.loc_lvl_1_1.id} + ) + + cls.out_1 = cls.StockLocation.create( + {"name": "OUT-1", "barcode": "OUT-1", "location_id": cls.out.id} + ) + + # products + Product = cls.env["product.product"].sudo() + cls.uom_unit = cls.env.ref("uom.product_uom_unit") + cls.product_1 = Product.create( + {"name": "Wood", "type": "product", "uom_id": cls.uom_unit.id} + ) + cls.product_2 = Product.create( + {"name": "Stone", "type": "product", "uom_id": cls.uom_unit.id} + ) + cls.product_1.route_ids |= cls.wh.delivery_route_id + cls.product_2.route_ids |= cls.wh.delivery_route_id + + cls.release_channel_1 = ( + cls.env["stock.release.channel"].sudo().create({"name": "Channel Test 1"}) + ) + cls.release_channel_2 = ( + cls.env["stock.release.channel"].sudo().create({"name": "Channel Test 2"}) + ) + + cls.out.release_channel_restriction = "same" + + def setUp(self): + super().setUp() + self.service = self.get_service( + "location_content_transfer", menu=self.menu, profile=self.profile + ) + self.stock_action = self.service._actions_for("stock") + + def test_set_destination(self): + manager = ( + self.env["res.users"] + .sudo() + .create({"name": "Manager", "login": "stock_manager"}) + ) + manager.groups_id |= self.env.ref("stock.group_stock_manager") + self.env.user.groups_id |= self.env.ref("stock.group_stock_user") + self.env["stock.quant"].with_user(manager).with_context( + inventory_mode=True + ).create( + { + "product_id": self.product_2.id, + "inventory_quantity": 10.0, + "location_id": self.loc_lvl_1_1_1.id, + } + )._apply_inventory() + self.env["stock.quant"].with_user(manager).with_context( + inventory_mode=True + ).create( + { + "product_id": self.product_1.id, + "inventory_quantity": 10.0, + "location_id": self.loc_lvl_1_1_2.id, + } + )._apply_inventory() + self.loc_lvl_1_1_2.barcode = "LVL_1_1_2" + self.loc_lvl_1_1_1.barcode = "LVL_1_1_1" + + values = { + "warehouse_id": self.wh, + } + + self.env["procurement.group"].run( + [ + self.env["procurement.group"].Procurement( + self.product_1, + 5.0, + self.product_1.uom_id, + self.customers, + self.product_1.display_name, + self.product_1.display_name, + self.env.company, + values, + ) + ] + ) + + ship_move = self.env["stock.move"].search( + [ + ("location_dest_id", "=", self.customers.id), + ("product_id", "=", self.product_1.id), + ] + ) + ship_move.picking_id.release_channel_id = self.release_channel_1 + + pick_move = self.env["stock.move"].search( + [ + ("location_id", "=", self.stock.id), + ("product_id", "=", self.product_1.id), + ] + ) + + pick_move._action_assign() + + # Assign user to move + pick_move.move_line_ids.qty_done = 5.0 + pick_move.picking_id.user_id = self.env.user + + response = self.service.dispatch( + "set_destination_all", + params={ + "location_id": self.loc_lvl_1_1_2.id, + "barcode": self.out_1.barcode, + }, + ) + + self.assertEqual(pick_move.location_dest_id, self.out_1) + self.assertEqual( + self.out_1.current_release_channel_restriction_id, self.release_channel_1 + ) + + self.env["procurement.group"].run( + [ + self.env["procurement.group"].Procurement( + self.product_2, + 5.0, + self.product_2.uom_id, + self.customers, + self.product_2.display_name, + self.product_2.display_name, + self.env.company, + values, + ) + ] + ) + + ship_move = self.env["stock.move"].search( + [ + ("location_dest_id", "=", self.customers.id), + ("product_id", "=", self.product_2.id), + ] + ) + ship_move.picking_id.release_channel_id = self.release_channel_2 + + pick_move = self.env["stock.move"].search( + [ + ("location_id", "=", self.stock.id), + ("product_id", "=", self.product_2.id), + ] + ) + + pick_move._action_assign() + + pick_move.move_line_ids.qty_done = 5.0 + pick_move.picking_id.user_id = self.env.user + + response = self.service.dispatch( + "set_destination_all", + params={ + "location_id": self.loc_lvl_1_1_1.id, + "barcode": self.out_1.barcode, + }, + ) + + self.assertEqual( + "You cannot place it here", response.get("message").get("body") + ) diff --git a/test-requirements.txt b/test-requirements.txt index 689482e20df..cd3987e5622 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1,4 @@ vcrpy-unittest odoo_test_helper + +odoo-addon-stock-location-release-channel-restriction @ git+https://github.com/OCA/stock-logistics-warehouse@refs/pull/2521/head#subdirectory=setup/stock_location_release_channel_restriction