Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
78014325 by Cédric Krier at 2023-05-10T00:06:56+02:00
Fix test for multiselection :string in record values

Closes #12261
- - - - -
de713297 by Cédric Krier at 2023-05-10T00:19:57+02:00
Eagerly read string value of multiselection fields

The changeset 2763339d88d5 implemented the rendering of multiselection from
:string but the record does not read them.
- - - - -


5 changed files:

- sao/CHANGELOG
- sao/src/model.js
- sao/src/view/tree.js
- tryton/CHANGELOG
- tryton/tryton/gui/window/view_form/model/record.py


Changes:

=====================================
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


=====================================
sao/src/model.js
=====================================
@@ -669,7 +669,8 @@
             }
             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');
@@ -672,9 +673,9 @@
             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];
                 }


=====================================
sao/src/view/tree.js
=====================================
@@ -2631,7 +2631,7 @@
         },
         update_text: function(cell, record) {
             if (!this.tree.editable &&
-                    (this.field_name + ':string' in record._value)) {
+                    (this.field_name + ':string' in record._values)) {
                 var text_value = record._values[this.field_name + ':string'];
                 cell.text(text_value).attr('title', text_value);
             } else {


=====================================
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
 


=====================================
tryton/tryton/gui/window/view_form/model/record.py
=====================================
@@ -83,7 +83,7 @@
                 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 @@
             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]



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/compare/80d8b04fa6d6f29323ad04d01f9a5081d75e947f...de713297b6e7a908b7b907463b7e11ded62e3c07

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/compare/80d8b04fa6d6f29323ad04d01f9a5081d75e947f...de713297b6e7a908b7b907463b7e11ded62e3c07
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to