From 031088f190de0a6aca20ec4629bb4dd9f2bfe4fc Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Tue, 19 Jan 2021 12:49:42 +0000 Subject: [PATCH] [FIX] stock: lots ids disapear after onchange. Use case to reproduce: - Go to MO form produce at least 2 units of a product with a component tracked by serial number. - Edit the producing quantity to 1.0 - Save - Edit the producing quantity to 2.0 The move lines are removed. It happens because the lot_ids field is empty and thus the setter remove the existing stock.move.line. It's empty because the compute try to do a match on existing id. However the stock.move in the onchange could have a new virtual id. fine tuning of commit 8dfee8cb2d60942641b73eaa6489b02aa378c5ac closes odoo/odoo#64788 X-original-commit: a3ab5c3a73243e6f4d5662ee27765439ba9b5363 Signed-off-by: Arnold Moyaux --- addons/stock/models/stock_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 85212c3af1e..7020a1cc229 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -472,7 +472,7 @@ class StockMove(models.Model): ) lots_by_move_id_list.append({by_move['move_id'][0]: by_move['lot_ids'] for by_move in lots_by_move_id}) for move in self: - move.lot_ids = lots_by_move_id_list[0 if move.picking_type_id.show_reserved else 1].get(move.id, []) + move.lot_ids = lots_by_move_id_list[0 if move.picking_type_id.show_reserved else 1].get(move._origin.id, []) def _set_lot_ids(self): for move in self: