details:   https://code.tryton.org/tryton/commit/463f49bfc034
branch:    default
user:      Cédric Krier <[email protected]>
date:      Thu Mar 26 18:00:24 2026 +0100
description:
        Do not use relation field from default order when fetching One2Many 
records

        The records are already ordered by the field id to be grouped later so 
such
        order clause has no impact on the result.
        But they require joins that may not be needed otherwise.

        Closes #14716
diffstat:

 trytond/trytond/model/fields/one2many.py |  4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diffs (14 lines):

diff -r 6b38bc7a3ca0 -r 463f49bfc034 trytond/trytond/model/fields/one2many.py
--- a/trytond/trytond/model/fields/one2many.py  Tue Apr 07 09:35:21 2026 +0200
+++ b/trytond/trytond/model/fields/one2many.py  Thu Mar 26 18:00:24 2026 +0100
@@ -154,7 +154,9 @@
         if self.order:
             order += self.order
         elif Target._order:
-            order += Target._order
+            order += [
+                (oexpr, otype) for oexpr, otype in Target._order
+                if not oexpr.startswith(f'{self.field}.')]
         if reference_key:
             references = ['%s,%s' % (model.__name__, x) for x in ids]
             clause = [(self.field, 'in', references)]

Reply via email to