diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index c523dd95e7f..dd0635a11f8 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -208,6 +208,7 @@ class StockMoveLine(models.Model): packaging=self.move_id.product_packaging_id) def _apply_putaway_strategy(self): + self = self.with_context(do_not_unreserve=True) for package, smls in groupby(self, lambda sml: sml.result_package_id): smls = self.env['stock.move.line'].concat(*smls) excluded_smls = smls diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py index c9d98ee0d92..44fb39f3c5f 100644 --- a/addons/stock/tests/test_stock_flow.py +++ b/addons/stock/tests/test_stock_flow.py @@ -2220,3 +2220,25 @@ class TestStockFlow(TestStockCommon): self.assertEqual(picking.state, 'cancel') self.assertEqual(move.state, 'cancel') self.assertEqual(scrap.move_id.state, 'done') + + def test_receive_tracked_product(self): + self.productA.tracking = 'serial' + type_in = self.env['stock.picking.type'].browse(self.picking_type_in) + + receipt_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=True)) + receipt_form.picking_type_id = type_in + with receipt_form.move_ids_without_package.new() as move_line: + move_line.product_id = self.productA + receipt = receipt_form.save() + + move_form = Form(receipt.move_ids, view='stock.view_stock_move_nosuggest_operations') + with move_form.move_line_nosuggest_ids.new() as line: + line.lot_name = "USN01" + move_form.save() + + receipt.button_validate() + quant = self.productA.stock_quant_ids.filtered(lambda q: q.location_id.id == self.stock_location) + + self.assertEqual(receipt.state, 'done') + self.assertEqual(quant.quantity, 1.0) + self.assertEqual(quant.lot_id.name, 'USN01')