From e76d45a2ff37a0eda380c31cd42cd26467cbfd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 10 May 2023 00:19:57 +0200 Subject: [PATCH] Eagerly read string value of multiselection fields The changeset 2763339d88d5 implemented the rendering of multiselection from :string but the record does not read them. --- sao/CHANGELOG | 1 + sao/src/model.js | 10 ++++++---- tryton/CHANGELOG | 1 + tryton/tryton/gui/window/view_form/model/record.py | 5 +++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sao/CHANGELOG b/sao/CHANGELOG index 0e7c42fc6f..b4b0704b41 100644 --- a/sao/CHANGELOG +++ b/sao/CHANGELOG @@ -1,3 +1,4 @@ +* Eagerly read string value of multiselection fields * Use locale timezone for CSV in locale format Version 6.8.0 - 2023-05-01 diff --git a/sao/src/model.js b/sao/src/model.js index c24c15fd60..ad3797b761 100644 --- a/sao/src/model.js +++ b/sao/src/model.js @@ -669,12 +669,13 @@ } var fnames_to_fetch = fnames.slice(); var rec_named_fields = ['many2one', 'one2one', 'reference']; + const selection_fields = ['selection', 'multiselection']; for (const fname of fnames) { var fdescription = this.model.fields[fname].description; if (~rec_named_fields.indexOf(fdescription.type)) fnames_to_fetch.push(fname + '.rec_name'); - else if ((fdescription.type == 'selection') && - ((fdescription.loading || 'lazy') == 'eager')) { + else if (~selection_fields.indexOf(fdescription.type) && + ((fdescription.loading || 'lazy') == 'eager')) { fnames_to_fetch.push(fname + ':string'); } } @@ -842,8 +843,9 @@ (field instanceof Sao.field.Reference)) { related = name + '.'; this._values[related] = values[related] || {}; - } else if ((field instanceof Sao.field.Selection) && - (name + ':string' in values)){ + } else if (((field instanceof Sao.field.Selection) || + (field instanceof Sao.field.MultiSelection)) && + (name + ':string' in values)) { related = name + ':string'; this._values[related] = values[related]; } diff --git a/tryton/CHANGELOG b/tryton/CHANGELOG index a684949667..37571a8739 100644 --- a/tryton/CHANGELOG +++ b/tryton/CHANGELOG @@ -1,3 +1,4 @@ +* Eagerly read string value of multiselection fields * Use locale timezone for CSV in locale format * Display sum on column header diff --git a/tryton/tryton/gui/window/view_form/model/record.py b/tryton/tryton/gui/window/view_form/model/record.py index 52bc28a99c..fd383cd9ad 100644 --- a/tryton/tryton/gui/window/view_form/model/record.py +++ b/tryton/tryton/gui/window/view_form/model/record.py @@ -83,7 +83,7 @@ class Record: f_attrs = self.group.fields[fname].attrs if f_attrs['type'] in {'many2one', 'one2one', 'reference'}: fnames.append('%s.rec_name' % fname) - elif (f_attrs['type'] == 'selection' + elif (f_attrs['type'] in {'selection', 'multiselection'} and f_attrs.get('loading', 'lazy') == 'eager'): fnames.append('%s:string' % fname) if 'rec_name' not in fnames: @@ -480,7 +480,8 @@ class Record: if isinstance(field, (fields.M2OField, fields.ReferenceField)): related = fieldname + '.' self.value[related] = val.get(related) or {} - elif (isinstance(field, fields.SelectionField) + elif (isinstance(field, ( + fields.SelectionField, fields.MultiSelectionField)) and fieldname + ':string' in val): related = fieldname + ':string' self.value[related] = val[related]