From 6fe846ec2f070052369b42d9ba83690ab69d7a9f Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 31 Jul 2017 10:28:24 +0200 Subject: [PATCH] [FIX] purchase: Wrong scheduled date for backorder Fine tuning of this commit:7333f5e When the PO lines were not ordered according to the scheduled date, the scheduled date of the picking was wrong when delivering. opw:752192 --- addons/purchase/purchase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 23f1f8bebef..6e07b1ebddf 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -358,7 +358,7 @@ class PurchaseOrder(models.Model): moves = order.order_line.filtered(lambda r: r.product_id.type in ['product', 'consu'])._create_stock_moves(picking) move_ids = moves.action_confirm() seq = 0 - for move in moves: + for move in sorted(moves, key=lambda move: move.date_expected): seq += 5 move.sequence = seq moves = self.env['stock.move'].browse(move_ids)