details:   https://code.tryton.org/tryton/commit/a9d8deaa4897
branch:    default
user:      Cédric Krier <[email protected]>
date:      Tue Oct 21 12:14:04 2025 +0200
description:
        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
diffstat:

 sao/src/model.js                                   |  3 ++-
 tryton/tryton/gui/window/view_form/model/record.py |  3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r c3e0f5727931 -r a9d8deaa4897 sao/src/model.js
--- a/sao/src/model.js  Tue Nov 04 10:28:04 2025 +0100
+++ b/sao/src/model.js  Tue Oct 21 12:14:04 2025 +0200
@@ -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 -r c3e0f5727931 -r a9d8deaa4897 
tryton/tryton/gui/window/view_form/model/record.py
--- a/tryton/tryton/gui/window/view_form/model/record.py        Tue Nov 04 
10:28:04 2025 +0100
+++ b/tryton/tryton/gui/window/view_form/model/record.py        Tue Oct 21 
12:14:04 2025 +0200
@@ -115,7 +115,8 @@
                 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:

Reply via email to