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
This commit is contained in:
@@ -154,7 +154,9 @@ class One2Many(Field):
|
||||
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)]
|
||||
|
||||
Reference in New Issue
Block a user