From a251afccbee9740cb1ca67028b88e8b28635d1c6 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Mon, 7 Aug 2017 14:40:49 +0200 Subject: [PATCH] [FIX] stock: traceability downstream order and date The traceability report in downstream was looking for newer move lines instead of older ones, which leads to not showing all related traceable moves. We also changed the sort order of the move_lines in downstream --- addons/stock/models/stock_traceability.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_traceability.py b/addons/stock/models/stock_traceability.py index c40e7a76a47..8a3f3747ce0 100644 --- a/addons/stock/models/stock_traceability.py +++ b/addons/stock/models/stock_traceability.py @@ -57,7 +57,7 @@ class MrpStockReport(models.TransientModel): ('lot_id', '=', move_line.lot_id.id), ('location_id', '=', move_line.location_dest_id.id), ('id', '!=', move_line.id), - ('date', '<', move_line.date), + ('date', '>', move_line.date), ]) if res: res |= self.get_move_lines_downstream(res) @@ -278,7 +278,10 @@ class MrpStockReport(models.TransientModel): else: for move_line in obj_ids: final_vals += self.make_dict_head(level, stream=stream, parent_id=line_id, model=model or 'stock.pack.operation', move_line=move_line) - final_vals = sorted(final_vals, key=lambda v: v['date'], reverse=True) + reverse_sort = True + if stream == "downstream": + reverse_sort = False + final_vals = sorted(final_vals, key=lambda v: v['date'], reverse=reverse_sort) lines = self.final_vals_to_lines(final_vals, level) return lines