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/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..53380c3ea 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, @@ -155,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), ] @@ -207,9 +209,30 @@ 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, + package_id=line.package_id, + owner_id=line.owner_id, + strict=False, + ) + move._update_reserved_quantity( + line.move_quantity, + 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, + # 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 +278,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)