mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] stock_reserve: Avoid creation of pickings when confirming stock reservations
TT41080
This commit is contained in:
committed by
Chris Mann
parent
c3c7522d68
commit
64a60f6a7d
@@ -123,8 +123,9 @@ class StockReservation(models.Model):
|
||||
A date until which the product is reserved can be specified.
|
||||
"""
|
||||
self.write({"date": fields.Datetime.now()})
|
||||
self.mapped("move_id")._action_confirm(merge=False)
|
||||
self.mapped("move_id.picking_id").action_assign()
|
||||
# Don't call _action_confirm() method to prevent assign picking
|
||||
self.mapped("move_id").write({"state": "confirmed"})
|
||||
self.mapped("move_id")._action_assign()
|
||||
return True
|
||||
|
||||
def release_reserve(self):
|
||||
@@ -133,8 +134,6 @@ class StockReservation(models.Model):
|
||||
"""
|
||||
moves = self.mapped("move_id")
|
||||
moves._action_cancel()
|
||||
# HACK: For avoiding to accumulate all reservations in the same picking
|
||||
moves.write({"picking_id": False})
|
||||
return True
|
||||
|
||||
def _get_state_domain_release_reserve(self, mode):
|
||||
|
||||
@@ -34,9 +34,11 @@ class TestStockReserve(common.TransactionCase):
|
||||
def test_reservation_and_reservation_release(self):
|
||||
reservation_1 = self._create_stock_reservation(6)
|
||||
reservation_1.reserve()
|
||||
self.assertFalse(reservation_1.picking_id)
|
||||
self.assertEqual(self.product.virtual_available, 4)
|
||||
reservation_2 = self._create_stock_reservation(1)
|
||||
reservation_2.reserve()
|
||||
self.assertFalse(reservation_2.picking_id)
|
||||
self.assertEqual(self.product.virtual_available, 3)
|
||||
reservation_1.release_reserve()
|
||||
self.assertEqual(self.product.virtual_available, 9)
|
||||
@@ -45,6 +47,7 @@ class TestStockReserve(common.TransactionCase):
|
||||
reservation_1 = self._create_stock_reservation(6)
|
||||
reservation_1.date_validity = fields.Date.from_string("2021-01-01")
|
||||
reservation_1.reserve()
|
||||
self.assertFalse(reservation_1.picking_id)
|
||||
self.assertEqual(self.product.virtual_available, 4)
|
||||
cron = self.env.ref("stock_reserve.ir_cron_release_stock_reservation")
|
||||
cron.method_direct_trigger()
|
||||
@@ -53,6 +56,7 @@ class TestStockReserve(common.TransactionCase):
|
||||
def test_cron_reserve(self):
|
||||
reservation_1 = self._create_stock_reservation(11)
|
||||
reservation_1.reserve()
|
||||
self.assertFalse(reservation_1.picking_id)
|
||||
self.assertEqual(reservation_1.state, "partially_available")
|
||||
self.env["stock.quant"].create(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user