diff options
| author | Martin Geubelle <mge@odoo.com> | 2017-11-02 13:53:43 +0100 |
|---|---|---|
| committer | Martin Geubelle <mge@odoo.com> | 2017-11-02 16:02:11 +0100 |
| commit | 3e63f01cf1c3acab24221f1033d5d6ae6b33303f (patch) | |
| tree | 60b19bf0c48e039c55942dcde359eeb864561541 /addons/web/static/src/js | |
| parent | b2466c80ae37f92e9e88f941e72b24288f9e4572 (diff) | |
[FIX] web: FieldSelector: add model in field attributes
The key `model` was missing in the FieldSelector selected fields.
The model can be useful for example to create a one2many related field.
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/widgets/model_field_selector.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/addons/web/static/src/js/widgets/model_field_selector.js b/addons/web/static/src/js/widgets/model_field_selector.js index b82c2ed1963..81abfbe0d6c 100644 --- a/addons/web/static/src/js/widgets/model_field_selector.js +++ b/addons/web/static/src/js/widgets/model_field_selector.js @@ -204,7 +204,7 @@ var ModelFieldSelector = Widget.extend({ context: this.getSession().user_context, }) .then((function (fields) { - modelFieldsCache.cache[model] = sortFields(fields); + modelFieldsCache.cache[model] = sortFields(fields, model); }).bind(this)); } return def.then((function () { @@ -299,7 +299,7 @@ var ModelFieldSelector = Widget.extend({ _pushPageData: function (model) { var def; if (this.model === model && this.options.fields) { - def = $.when(sortFields(this.options.fields)); + def = $.when(sortFields(this.options.fields, model)); } else { def = this._getModelFieldsFromCache(model, this.options.filters); } @@ -539,14 +539,21 @@ return ModelFieldSelector; * the final array contain an additional key "name" with the field name. * * @param {Object} fields - the mapping field name -> field info + * @param {string} model * @returns {Object[]} the field infos sorted by field "string" (field infos - * contain an additional key "name" with the field name) + * contain additional keys "model" and "name" with the field + * name) */ -function sortFields(fields) { +function sortFields(fields, model) { return _.chain(fields) .pairs() .sortBy(function (p) { return p[1].string; }) - .map(function (p) { return _.extend({name: p[0]}, p[1]); }) + .map(function (p) { + return _.extend({ + name: p[0], + model: model, + }, p[1]); + }) .value(); } }); |
