From ff2c9f7bc30315c1c07dcee74eea92db8d7ded00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 21 Oct 2025 12:14:04 +0200 Subject: [PATCH] Load sub-fields of xxx2Many only for lazy loading The sub-fields are not needed for eager loading view like the tree because they are rendered with only the number of records. Closes #14305 --- sao/src/model.js | 3 ++- tryton/tryton/gui/window/view_form/model/record.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sao/src/model.js b/sao/src/model.js index 0d278cdc79..9ae15d2b31 100644 --- a/sao/src/model.js +++ b/sao/src/model.js @@ -721,7 +721,8 @@ ((fdescription.loading || 'lazy') == 'eager')) { fnames_to_fetch.push(fname + ':string'); } else if ( - ['many2many', 'one2many'].includes(fdescription.type)) { + ['many2many', 'one2many'].includes(fdescription.type) && + (loading == 'lazy')) { var sub_fields = get_x2m_sub_fields(fdescription, fname); fnames_to_fetch = [ ...fnames_to_fetch, ...sub_fields]; if (sub_fields.length > 0) { diff --git a/tryton/tryton/gui/window/view_form/model/record.py b/tryton/tryton/gui/window/view_form/model/record.py index b61c8d8aef..665bb1e4f7 100644 --- a/tryton/tryton/gui/window/view_form/model/record.py +++ b/tryton/tryton/gui/window/view_form/model/record.py @@ -115,7 +115,8 @@ class Record: elif (f_attrs['type'] in {'selection', 'multiselection'} and f_attrs.get('loading', 'lazy') == 'eager'): fnames.append('%s:string' % fname) - elif f_attrs['type'] in {'many2many', 'one2many'}: + elif (f_attrs['type'] in {'many2many', 'one2many'} + and loading == 'lazy'): sub_fields = get_x2m_sub_fields(f_attrs, fname) fnames.extend(sub_fields) if sub_fields: