[FIX] stock: immediate transfer w/ tracked product
How to reproduce: - Create a tracked product; - In the receipt picking type form view, for the lot and serial numbers, uncheck "Create New" and "Use Existing ones"; - Create a planned receipt for some of this tracked product; - Confirm and validate the receipt: It opens the "Immediate Transfer" wizard; - Apply the immediate transfer: -> It asks if you want to create a backorder. Since the picking type doesn't use new or existing LN/SN, it accepts to be confirmed even if some move lines for tracked product have no tracking numbers. The issue was, when a `stock.move` sets its done quantity to its reserved quantity, if its product is tracked, it doesn't change its done quantity if it has no tracking number, regardless the picking type's configuration. OPW-3186155 closes odoo/odoo#115234 X-original-commit: 89567288e9c134f1262e8ba8b5fc65f730a239cf Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com> Signed-off-by: Steve Van Essche <svs@odoo.com>
This commit is contained in:
@@ -2033,7 +2033,9 @@ 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 not (move_line.lot_id or move_line.lot_name):
|
||||
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
|
||||
|
||||
|
||||
@@ -4575,6 +4575,32 @@ class StockMove(TransactionCase):
|
||||
self.assertEqual(receipt2.state, 'done')
|
||||
self.assertEqual(receipt3.state, 'done')
|
||||
|
||||
def test_immediate_validate_9_tracked_move_with_0_qty_done(self):
|
||||
"""When trying to validate a picking as an immediate transfer, the done
|
||||
quantity of tracked move should be automatically fulfilled if the
|
||||
picking type doesn't use new or existing LN/SN."""
|
||||
picking_type_receipt = self.env.ref('stock.picking_type_in')
|
||||
picking_type_receipt.use_create_lots = False
|
||||
picking_type_receipt.use_existing_lots = False
|
||||
|
||||
picking_form = Form(self.env['stock.picking'])
|
||||
picking_form.picking_type_id = picking_type_receipt
|
||||
with picking_form.move_ids_without_package.new() as move:
|
||||
move.product_id = self.product_serial
|
||||
move.product_uom_qty = 4
|
||||
with picking_form.move_ids_without_package.new() as move:
|
||||
move.product_id = self.product_lot
|
||||
move.product_uom_qty = 20
|
||||
receipt = picking_form.save()
|
||||
receipt.action_confirm()
|
||||
|
||||
immediate_wizard = receipt.button_validate()
|
||||
immediate_wizard_form = Form(
|
||||
self.env[immediate_wizard['res_model']].with_context(immediate_wizard['context'])
|
||||
).save()
|
||||
immediate_wizard_form.process()
|
||||
self.assertEqual(receipt.state, 'done')
|
||||
|
||||
def test_set_quantity_done_1(self):
|
||||
move1 = self.env['stock.move'].create({
|
||||
'name': 'test_set_quantity_done_1',
|
||||
|
||||
Reference in New Issue
Block a user