From ae91f75cdf2e4c40658c7c78acf90d8955fe900d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 19 Apr 2022 23:40:08 +0200 Subject: [PATCH] Use for...in to iterate over field names from the list of values The elements of list of values are objects. Also we can use a Set instead of an object to build the unique list of field names. issue11415 review407291002 --- src/model.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/model.js b/src/model.js index fb84af9f54..67b8b4dc84 100644 --- a/src/model.js +++ b/src/model.js @@ -2107,20 +2107,20 @@ } if (mode == 'list values') { var context = this.get_context(record); - var field_names = {}; + let field_names = new Set(); for (const val of value) { - for (var fieldname of val) { + for (const fieldname in val) { if (!(fieldname in group.model.fields) && (!~fieldname.indexOf('.'))) { - field_names[fieldname] = true; + field_names.add(fieldname); } } } - if (!jQuery.isEmptyObject(field_names)) { + if (field_names.size) { var args = { 'method': 'model.' + this.description.relation + '.fields_get', - 'params': [Object.keys(field_names), context] + 'params': [Array.from(field_names), context] }; var fields; try {