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"/>
+