diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 335db29f46f..30844ab6da9 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -2027,11 +2027,11 @@ Please change the quantity done or the rounding precision of your unit of measur if move.state not in ('partially_available', 'assigned'): continue for move_line in move.move_line_ids: - if move.has_tracking != 'none' and ( - (move.picking_type_id.use_existing_lots and not move_line.lot_id) or - (move.picking_type_id.use_create_lots and not move_line.lot_name)): - continue - move_line.qty_done = move_line.reserved_uom_qty + if move.has_tracking == 'none' or\ + (move.picking_type_id.use_existing_lots and move_line.lot_id) or\ + (move.picking_type_id.use_create_lots and move_line.lot_name) or\ + (not move.picking_type_id.use_existing_lots and not move.picking_type_id.use_create_lots): + move_line.qty_done = move_line.reserved_uom_qty def _clear_quantities_to_zero(self): self.filtered(lambda m: m.state in ('partially_available', 'assigned')).move_line_ids.qty_done = 0 diff --git a/addons/stock/tests/test_move.py b/addons/stock/tests/test_move.py index 682619157a4..f45ac2cea10 100644 --- a/addons/stock/tests/test_move.py +++ b/addons/stock/tests/test_move.py @@ -4602,6 +4602,36 @@ class StockMove(TransactionCase): immediate_wizard_form.process() self.assertEqual(receipt.state, 'done') + def test_immediate_validate_10_tracked_move_without_backorder(self): + """ + Create a picking for a tracked product, validate it as an + immediate transfer, and ensure that the backorder wizard is + not triggered when the qty is reserved. + """ + picking_type_internal = self.env.ref('stock.picking_type_internal') + picking_type_internal.use_create_lots = True + picking_type_internal.use_existing_lots = True + lot = self.env['stock.lot'].create({ + 'name': 'Lot 1', + 'product_id': self.product_lot.id, + 'company_id': self.env.company.id, + }) + self.env['stock.quant']._update_available_quantity(self.product_lot, self.stock_location, 10, lot_id=lot) + picking_form = Form(self.env['stock.picking']) + picking_form.picking_type_id = picking_type_internal + with picking_form.move_ids_without_package.new() as move: + move.product_id = self.product_lot + move.product_uom_qty = 4 + internal_transfer = picking_form.save() + internal_transfer.action_confirm() + + immediate_wizard = internal_transfer.button_validate() + immediate_wizard_form = Form( + self.env[immediate_wizard['res_model']].with_context(immediate_wizard['context']) + ).save() + immediate_wizard_form.process() + self.assertEqual(internal_transfer.state, 'done') + def test_set_quantity_done_1(self): move1 = self.env['stock.move'].create({ 'name': 'test_set_quantity_done_1',