From 9838a01835523b82510a51a6b00e67dfa21c77d2 Mon Sep 17 00:00:00 2001 From: kanda999 Date: Wed, 15 Jul 2026 02:42:51 +0000 Subject: [PATCH] [6792][ADD] mrp_stock_move_demand_editable --- mrp_stock_move_demand_editable/README.rst | 116 +++++ mrp_stock_move_demand_editable/__init__.py | 1 + .../__manifest__.py | 16 + .../models/__init__.py | 1 + .../models/stock_move.py | 33 ++ mrp_stock_move_demand_editable/pyproject.toml | 3 + .../readme/CONTRIBUTORS.md | 2 + .../readme/DESCRIPTION.md | 9 + .../readme/USAGE.md | 17 + .../static/description/index.html | 454 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_stock_move_demand_editable.py | 92 ++++ 12 files changed, 745 insertions(+) create mode 100644 mrp_stock_move_demand_editable/README.rst create mode 100644 mrp_stock_move_demand_editable/__init__.py create mode 100644 mrp_stock_move_demand_editable/__manifest__.py create mode 100644 mrp_stock_move_demand_editable/models/__init__.py create mode 100644 mrp_stock_move_demand_editable/models/stock_move.py create mode 100644 mrp_stock_move_demand_editable/pyproject.toml create mode 100644 mrp_stock_move_demand_editable/readme/CONTRIBUTORS.md create mode 100644 mrp_stock_move_demand_editable/readme/DESCRIPTION.md create mode 100644 mrp_stock_move_demand_editable/readme/USAGE.md create mode 100644 mrp_stock_move_demand_editable/static/description/index.html create mode 100644 mrp_stock_move_demand_editable/tests/__init__.py create mode 100644 mrp_stock_move_demand_editable/tests/test_stock_move_demand_editable.py diff --git a/mrp_stock_move_demand_editable/README.rst b/mrp_stock_move_demand_editable/README.rst new file mode 100644 index 0000000..760db4f --- /dev/null +++ b/mrp_stock_move_demand_editable/README.rst @@ -0,0 +1,116 @@ +============================== +MRP Stock Move Demand Editable +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d04cca2dea47ee7fe1ad3ddc805c7d0eca64daa3700a1a586353bc71adc2f1d0 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.0/mrp_stock_move_demand_editable + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-18-0/manufacture-18-0-mrp_stock_move_demand_editable + :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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +When manufacturing is configured with 2 or 3 steps (*Pick components +then manufacture*), Odoo generates a *Pick Components* transfer to move +the raw materials to the production area. The demand (initial requested +quantity) of this transfer is locked and cannot be changed. + +This module makes the demand quantity of those *Pick Components* +transfers editable, so a different quantity than the one required by the +manufacturing order can be requested (for example, moving a larger +quantity to the shop floor and returning the surplus afterwards). + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Prerequisite: the warehouse must be configured with *Pick components +then manufacture* (2 steps) or *Pick components, manufacture, then store +products* (3 steps). + +1. Confirm a manufacturing order. Odoo creates the related *Pick + Components* transfer. +2. Open the transfer. The **Demand** column of the operations is now + editable even though the transfer is locked. +3. Change the demand to the desired quantity (e.g. from 5 to 7). +4. Click **Check Availability** to reserve the new quantity. + +The reserved quantity is what the Barcode app shows as the target, so +step 4 is required for the operator to see the updated quantity on the +shop floor. + +The manufacturing order is not affected: it keeps consuming the quantity +defined by its bill of materials. Any surplus moved to the production +area can be returned to its original location using a return transfer. + +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 +------- + +* Quartile + +Contributors +------------ + +- `Quartile `__: + + - Kanda + +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-kanda999| image:: https://github.com/kanda999.png?size=40px + :target: https://github.com/kanda999 + :alt: kanda999 + +Current `maintainer `__: + +|maintainer-kanda999| + +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_move_demand_editable/__init__.py b/mrp_stock_move_demand_editable/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/mrp_stock_move_demand_editable/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_stock_move_demand_editable/__manifest__.py b/mrp_stock_move_demand_editable/__manifest__.py new file mode 100644 index 0000000..d7103e9 --- /dev/null +++ b/mrp_stock_move_demand_editable/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2026 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "MRP Stock Move Demand Editable", + "version": "18.0.1.0.0", + "category": "Manufacturing", + "summary": "Allow editing the demand quantity on manufacturing " + "component-pick transfers", + "author": "Quartile, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "license": "AGPL-3", + "development_status": "Beta", + "maintainers": ["kanda999"], + "depends": ["mrp"], + "installable": True, +} diff --git a/mrp_stock_move_demand_editable/models/__init__.py b/mrp_stock_move_demand_editable/models/__init__.py new file mode 100644 index 0000000..6bda2d2 --- /dev/null +++ b/mrp_stock_move_demand_editable/models/__init__.py @@ -0,0 +1 @@ +from . import stock_move diff --git a/mrp_stock_move_demand_editable/models/stock_move.py b/mrp_stock_move_demand_editable/models/stock_move.py new file mode 100644 index 0000000..e90ddfd --- /dev/null +++ b/mrp_stock_move_demand_editable/models/stock_move.py @@ -0,0 +1,33 @@ +# Copyright 2026 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + @api.depends("state", "picking_id.is_locked", "picking_type_id") + def _compute_is_initial_demand_editable(self): + """Make the initial demand editable on manufacturing "pick components" + transfers (2/3-step manufacturing). + + Core keeps the demand read-only once the transfer is locked and out of + the ``draft`` state. For component-pick transfers we want to be able to + request a different quantity than the one strictly needed by the + manufacturing order (e.g. move a larger quantity to the shop floor and + return the surplus afterwards), so we allow editing as long as the move + is not done or cancelled. + """ + super()._compute_is_initial_demand_editable() + candidates = self.filtered( + lambda m: not m.is_initial_demand_editable + and m.state not in ("done", "cancel") + and m.picking_type_id + ) + if not candidates: + return + pbm_type_ids = self.env["stock.warehouse"].sudo().search([]).pbm_type_id.ids + for move in candidates: + if move.picking_type_id.id in pbm_type_ids: + move.is_initial_demand_editable = True diff --git a/mrp_stock_move_demand_editable/pyproject.toml b/mrp_stock_move_demand_editable/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/mrp_stock_move_demand_editable/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mrp_stock_move_demand_editable/readme/CONTRIBUTORS.md b/mrp_stock_move_demand_editable/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..9a00f0e --- /dev/null +++ b/mrp_stock_move_demand_editable/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Quartile](https://www.quartile.co): + - Kanda diff --git a/mrp_stock_move_demand_editable/readme/DESCRIPTION.md b/mrp_stock_move_demand_editable/readme/DESCRIPTION.md new file mode 100644 index 0000000..3e74af2 --- /dev/null +++ b/mrp_stock_move_demand_editable/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +When manufacturing is configured with 2 or 3 steps (*Pick components then +manufacture*), Odoo generates a *Pick Components* transfer to move the raw +materials to the production area. The demand (initial requested quantity) of +this transfer is locked and cannot be changed. + +This module makes the demand quantity of those *Pick Components* transfers +editable, so a different quantity than the one required by the manufacturing +order can be requested (for example, moving a larger quantity to the shop +floor and returning the surplus afterwards). diff --git a/mrp_stock_move_demand_editable/readme/USAGE.md b/mrp_stock_move_demand_editable/readme/USAGE.md new file mode 100644 index 0000000..6658fcd --- /dev/null +++ b/mrp_stock_move_demand_editable/readme/USAGE.md @@ -0,0 +1,17 @@ +Prerequisite: the warehouse must be configured with *Pick components then +manufacture* (2 steps) or *Pick components, manufacture, then store products* +(3 steps). + +1. Confirm a manufacturing order. Odoo creates the related *Pick Components* + transfer. +2. Open the transfer. The **Demand** column of the operations is now editable + even though the transfer is locked. +3. Change the demand to the desired quantity (e.g. from 5 to 7). +4. Click **Check Availability** to reserve the new quantity. + +The reserved quantity is what the Barcode app shows as the target, so step 4 is +required for the operator to see the updated quantity on the shop floor. + +The manufacturing order is not affected: it keeps consuming the quantity +defined by its bill of materials. Any surplus moved to the production area can +be returned to its original location using a return transfer. diff --git a/mrp_stock_move_demand_editable/static/description/index.html b/mrp_stock_move_demand_editable/static/description/index.html new file mode 100644 index 0000000..1de706e --- /dev/null +++ b/mrp_stock_move_demand_editable/static/description/index.html @@ -0,0 +1,454 @@ + + + + + + +MRP Stock Move Demand Editable + + + +
+

MRP Stock Move Demand Editable

+ + +

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

+

When manufacturing is configured with 2 or 3 steps (Pick components +then manufacture), Odoo generates a Pick Components transfer to move +the raw materials to the production area. The demand (initial requested +quantity) of this transfer is locked and cannot be changed.

+

This module makes the demand quantity of those Pick Components +transfers editable, so a different quantity than the one required by the +manufacturing order can be requested (for example, moving a larger +quantity to the shop floor and returning the surplus afterwards).

+

Table of contents

+ +
+

Usage

+

Prerequisite: the warehouse must be configured with Pick components +then manufacture (2 steps) or Pick components, manufacture, then store +products (3 steps).

+
    +
  1. Confirm a manufacturing order. Odoo creates the related Pick +Components transfer.
  2. +
  3. Open the transfer. The Demand column of the operations is now +editable even though the transfer is locked.
  4. +
  5. Change the demand to the desired quantity (e.g. from 5 to 7).
  6. +
  7. Click Check Availability to reserve the new quantity.
  8. +
+

The reserved quantity is what the Barcode app shows as the target, so +step 4 is required for the operator to see the updated quantity on the +shop floor.

+

The manufacturing order is not affected: it keeps consuming the quantity +defined by its bill of materials. Any surplus moved to the production +area can be returned to its original location using a return transfer.

+
+
+

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

+
    +
  • Quartile
  • +
+
+
+

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:

+

kanda999

+

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_move_demand_editable/tests/__init__.py b/mrp_stock_move_demand_editable/tests/__init__.py new file mode 100644 index 0000000..911677e --- /dev/null +++ b/mrp_stock_move_demand_editable/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_move_demand_editable diff --git a/mrp_stock_move_demand_editable/tests/test_stock_move_demand_editable.py b/mrp_stock_move_demand_editable/tests/test_stock_move_demand_editable.py new file mode 100644 index 0000000..9ab942a --- /dev/null +++ b/mrp_stock_move_demand_editable/tests/test_stock_move_demand_editable.py @@ -0,0 +1,92 @@ +# Copyright 2026 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestStockMoveDemandEditable(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.warehouse = cls.env["stock.warehouse"].search( + [("company_id", "=", cls.env.company.id)], limit=1 + ) + # Configure 2-step manufacturing (pick components then manufacture). + cls.warehouse.write({"manufacture_steps": "pbm"}) + + cls.component = cls.env["product.product"].create( + {"name": "Test Component", "type": "consu", "is_storable": True} + ) + cls.finished = cls.env["product.product"].create( + {"name": "Test Finished", "type": "consu", "is_storable": True} + ) + cls.bom = cls.env["mrp.bom"].create( + { + "product_tmpl_id": cls.finished.product_tmpl_id.id, + "product_qty": 1.0, + "type": "normal", + "bom_line_ids": [ + (0, 0, {"product_id": cls.component.id, "product_qty": 1.0}) + ], + } + ) + + def _create_confirmed_mo(self, qty=5.0): + mo = self.env["mrp.production"].create( + { + "product_id": self.finished.id, + "product_qty": qty, + "bom_id": self.bom.id, + } + ) + mo.action_confirm() + return mo + + def test_pick_component_demand_editable(self): + """The demand of a locked pick-components transfer is editable.""" + self.assertTrue(self.warehouse.pbm_type_id) + mo = self._create_confirmed_mo(qty=5.0) + pick_move = mo.move_raw_ids.move_orig_ids + self.assertTrue(pick_move, "The pick-components move should be created.") + picking = pick_move.picking_id + self.assertEqual(picking.picking_type_id, self.warehouse.pbm_type_id) + # It is locked and past draft: core would normally lock the demand. + self.assertTrue(picking.is_locked) + self.assertNotIn(pick_move.state, ("draft", "done", "cancel")) + self.assertTrue( + pick_move.is_initial_demand_editable, + "The demand should be editable on a pick-components transfer.", + ) + # The demand can actually be changed (e.g. over-pick 5 -> 7). + pick_move.product_uom_qty = 7.0 + self.assertEqual(pick_move.product_uom_qty, 7.0) + + def test_regular_transfer_demand_not_editable(self): + """A regular locked internal transfer keeps its demand read-only.""" + internal_type = self.warehouse.int_type_id + self.assertNotEqual(internal_type, self.warehouse.pbm_type_id) + picking = self.env["stock.picking"].create( + { + "picking_type_id": internal_type.id, + "location_id": self.warehouse.lot_stock_id.id, + "location_dest_id": self.warehouse.pbm_loc_id.id, + } + ) + move = self.env["stock.move"].create( + { + "name": "Test regular move", + "product_id": self.component.id, + "product_uom_qty": 3.0, + "product_uom": self.component.uom_id.id, + "location_id": self.warehouse.lot_stock_id.id, + "location_dest_id": self.warehouse.pbm_loc_id.id, + "picking_id": picking.id, + } + ) + picking.action_confirm() + self.assertTrue(picking.is_locked) + self.assertNotIn(move.state, ("draft", "done", "cancel")) + self.assertFalse( + move.is_initial_demand_editable, + "A regular locked transfer should keep its demand read-only.", + )