From 3459ddefc90dda7b8a89a004405bc7eb72ae80b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 22 Oct 2023 22:38:57 +0200 Subject: [PATCH] Order downward lot trace by descending date --- modules/stock_lot/stock.py | 6 +++--- modules/stock_lot/stock.xml | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/stock_lot/stock.py b/modules/stock_lot/stock.py index 2041bf75d5..a26971d9ef 100644 --- a/modules/stock_lot/stock.py +++ b/modules/stock_lot/stock.py @@ -211,7 +211,7 @@ class LotTrace(ModelSQL, ModelView): @classmethod def __setup__(cls): super().__setup__() - cls._order.insert(0, ('date', 'ASC')) + cls._order.insert(0, ('date', None)) @classmethod def table_query(cls): @@ -265,7 +265,7 @@ class LotTrace(ModelSQL, ModelView): @classmethod def _trace_move_order_key(cls, move): - return (move.effective_date,) + return (move.effective_date, move.id) def get_upward_traces(self, name): return list(map(int, sorted(filter( @@ -278,7 +278,7 @@ class LotTrace(ModelSQL, ModelView): def get_downward_traces(self, name): return list(map(int, sorted(filter( self._is_trace_move, self._get_downward_traces()), - key=self._trace_move_order_key))) + key=self._trace_move_order_key, reverse=True))) def _get_downward_traces(self): return set() diff --git a/modules/stock_lot/stock.xml b/modules/stock_lot/stock.xml index a1f1c72c6a..e5a3253970 100644 --- a/modules/stock_lot/stock.xml +++ b/modules/stock_lot/stock.xml @@ -113,6 +113,10 @@ this repository contains the full copyright notices and license terms. --> name="domain" eval="[('lot', 'in', Eval('active_ids', []))]" pyson="1"/> + @@ -132,6 +136,10 @@ this repository contains the full copyright notices and license terms. --> name="domain" eval="[('lot', 'in', Eval('active_ids', []))]" pyson="1"/> +