From 8a3a856d74f21daa72d9af75fe94da97e31e3695 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Fri, 1 Dec 2023 08:07:36 +0630 Subject: [PATCH 1/4] [IMP] stock_move_location: improve planned transfer This commit ensures stock move lines with the selected lot_id are in the 'assigned' state when a specific product with a lot_id is chosen in the stock move location for a planned transfer. It resolves the issue where the selected lot_id for a specific product was being discarded and a different lot_id was inadvertently assigned in the move line. --- .../tests/test_move_location.py | 23 +++++++++++++++++- .../wizard/stock_move_location.py | 24 +++++++++++++++---- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/stock_move_location/tests/test_move_location.py b/stock_move_location/tests/test_move_location.py index 606a414de..a979057f1 100644 --- a/stock_move_location/tests/test_move_location.py +++ b/stock_move_location/tests/test_move_location.py @@ -124,7 +124,28 @@ class TestMoveLocation(TestsCommon): wizard.action_move_location() picking = wizard.picking_id self.assertEqual(picking.state, "assigned") - self.assertEqual(len(picking.move_line_ids), 7) + self.assertEqual( + len(wizard.stock_move_location_line_ids), len(picking.move_line_ids) + ) + wizard_lines = sorted( + [ + (line.product_id.id, line.lot_id.id, line.move_quantity) + for line in wizard.stock_move_location_line_ids + ], + key=lambda x: (x[0], x[1]), + ) + picking_lines = sorted( + [ + (line.product_id.id, line.lot_id.id, line.reserved_uom_qty) + for line in picking.move_line_ids + ], + key=lambda x: (x[0], x[1]), + ) + self.assertEqual( + wizard_lines, + picking_lines, + "Mismatch between move location lines and move lines", + ) self.assertEqual( sorted(picking.move_line_ids.mapped("reserved_uom_qty")), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 123.0], diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py index 69a621c64..f528de3e5 100644 --- a/stock_move_location/wizard/stock_move_location.py +++ b/stock_move_location/wizard/stock_move_location.py @@ -207,9 +207,26 @@ class StockMoveLocationWizard(models.TransientModel): def _create_move(self, picking, lines): self.ensure_one() move = self.env["stock.move"].create(self._get_move_values(picking, lines)) - if not self.env.context.get("planned"): + lines.create_move_lines(picking, move) + if self.env.context.get("planned"): for line in lines: - line.create_move_lines(picking, move) + available_quantity = self.env["stock.quant"]._get_available_quantity( + line.product_id, + line.origin_location_id, + lot_id=line.lot_id, + strict=False, + ) + move._update_reserved_quantity( + line.move_quantity, + available_quantity, + line.origin_location_id, + lot_id=line.lot_id, + strict=False, + ) + # Force the state to be assigned, instead of _action_assign, + # to avoid discarding the selected move_location_line. + move.state = "assigned" + move.move_line_ids.write({"state": "assigned"}) return move def _unreserve_moves(self): @@ -255,9 +272,6 @@ class StockMoveLocationWizard(models.TransientModel): moves_to_reassign = self._unreserve_moves() picking.button_validate() moves_to_reassign._action_assign() - else: - picking.action_confirm() - picking.action_assign() self.picking_id = picking return self._get_picking_action(picking.id) From 499b3338112f65f79a4ae7da09a4d85408bb25ab Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Thu, 14 Dec 2023 08:47:17 +0630 Subject: [PATCH 2/4] [FIX] stock_move_location: reserverd_quantity is always zero when move location from inventory adjustment --- stock_move_location/README.rst | 5 ++++- stock_move_location/readme/CONTRIBUTORS.md | 2 ++ stock_move_location/static/description/index.html | 6 +++++- stock_move_location/wizard/stock_move_location.py | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/stock_move_location/README.rst b/stock_move_location/README.rst index e09907b40..3c8413234 100644 --- a/stock_move_location/README.rst +++ b/stock_move_location/README.rst @@ -7,7 +7,7 @@ Move Stock Location !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:f94651ddb9871ffc275f587042e4db32c13f087592f5766ea5b466264d47dcd1 + !! source digest: sha256:87949c0c9182db96bf0d8e687697a678c119a5949d366f137d03a681d2fd44cd !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -139,6 +139,9 @@ Contributors - Iryna Vyshnevska - Alexei Rivera - Abraham Anes +- Quartile + + - Aung Ko Ko Lin Maintainers ----------- diff --git a/stock_move_location/readme/CONTRIBUTORS.md b/stock_move_location/readme/CONTRIBUTORS.md index c1630a5e8..fece6339c 100644 --- a/stock_move_location/readme/CONTRIBUTORS.md +++ b/stock_move_location/readme/CONTRIBUTORS.md @@ -11,3 +11,5 @@ - Iryna Vyshnevska \<\> - Alexei Rivera \<\> - Abraham Anes \<\> +- Quartile \<\> + - Aung Ko Ko Lin diff --git a/stock_move_location/static/description/index.html b/stock_move_location/static/description/index.html index 3d4a10c50..35f74ab15 100644 --- a/stock_move_location/static/description/index.html +++ b/stock_move_location/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:f94651ddb9871ffc275f587042e4db32c13f087592f5766ea5b466264d47dcd1 +!! source digest: sha256:87949c0c9182db96bf0d8e687697a678c119a5949d366f137d03a681d2fd44cd !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

This module allows to move entire location of products from one place to @@ -479,6 +479,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

  • Iryna Vyshnevska <i.vyshnevska@mobilunity.com>
  • Alexei Rivera <arivera@archeti.com>
  • Abraham Anes <abraham@studio73.es>
  • +
  • Quartile <https://www.quartile.co>
      +
    • Aung Ko Ko Lin
    • +
    +
  • diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py index f528de3e5..2fe212fb0 100644 --- a/stock_move_location/wizard/stock_move_location.py +++ b/stock_move_location/wizard/stock_move_location.py @@ -100,6 +100,7 @@ class StockMoveLocationWizard(models.TransientModel): "product_id": quant.product_id.id, "move_quantity": quant.quantity, "max_quantity": quant.quantity, + "reserved_quantity": quant.reserved_quantity, "origin_location_id": quant.location_id.id, "lot_id": quant.lot_id.id, "package_id": quant.package_id.id, @@ -128,6 +129,7 @@ class StockMoveLocationWizard(models.TransientModel): "product_id": quant.product_id.id, "move_quantity": qty, "max_quantity": qty, + "reserved_quantity": quant.reserved_quantity, "origin_location_id": quant.location_id.id, "lot_id": quant.lot_id.id, "package_id": quant.package_id.id, From 64c7900ebdea08fa961067b020e083b6ece80f04 Mon Sep 17 00:00:00 2001 From: Yoshi Tashiro Date: Sat, 23 Dec 2023 08:43:30 +0000 Subject: [PATCH 3/4] [FIX] stock_move_location: _get_locations_domain() Before this commit, the wrong company could be used in the domain. --- stock_move_location/wizard/stock_move_location.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py index 2fe212fb0..c2bc85eea 100644 --- a/stock_move_location/wizard/stock_move_location.py +++ b/stock_move_location/wizard/stock_move_location.py @@ -157,7 +157,7 @@ class StockMoveLocationWizard(models.TransientModel): def _get_locations_domain(self): return [ "|", - ("company_id", "=", self.env.user.company_id.id), + ("company_id", "=", self.env.company.id), ("company_id", "=", False), ] From 09d4188218a7dc40ad05d47746223b7b6f4e3dbf Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Thu, 25 Jan 2024 14:47:28 +0630 Subject: [PATCH 4/4] [UPD] add new parameters --- stock_move_location/wizard/stock_move_location.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py index c2bc85eea..53380c3ea 100644 --- a/stock_move_location/wizard/stock_move_location.py +++ b/stock_move_location/wizard/stock_move_location.py @@ -216,6 +216,8 @@ class StockMoveLocationWizard(models.TransientModel): line.product_id, line.origin_location_id, lot_id=line.lot_id, + package_id=line.package_id, + owner_id=line.owner_id, strict=False, ) move._update_reserved_quantity( @@ -223,6 +225,8 @@ class StockMoveLocationWizard(models.TransientModel): available_quantity, line.origin_location_id, lot_id=line.lot_id, + package_id=line.package_id, + owner_id=line.owner_id, strict=False, ) # Force the state to be assigned, instead of _action_assign,