summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/widgets/model_field_selector.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-01-19 15:06:29 +0100
committerqsm-odoo <qsm@odoo.com>2017-01-31 11:38:46 +0100
commit3c452a2ecd73c1f6d739fd4d8db1f5f6313fd752 (patch)
treebff7c6f569fa3e0860efc7762c26df47dcad1d73 /addons/web/static/src/js/widgets/model_field_selector.js
parent129be7ff78ca080f780814472943fe2c5e901429 (diff)
[FIX] web: document domain selector options correctly
The "ModelFieldSelector" widget has a "filters" option which can customize the fields which are displayed. The "DomainSelector" widget has of course the same option it can transmit to its internal "ModelFieldSelector" instance... but it was documented as "fs_filters" instead of "filters". Also, let the "ModelFieldSelector" document its own options and sets their defaults (instead of the "DomainSelector" widget).
Diffstat (limited to 'addons/web/static/src/js/widgets/model_field_selector.js')
-rw-r--r--addons/web/static/src/js/widgets/model_field_selector.js9
1 files changed, 6 insertions, 3 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 109b7ead7df..35c9e00d077 100644
--- a/addons/web/static/src/js/widgets/model_field_selector.js
+++ b/addons/web/static/src/js/widgets/model_field_selector.js
@@ -119,8 +119,9 @@ var ModelFieldSelector = Widget.extend({
/// @param model - a string with the model name (e.g. "res.partner")
/// @param chain - a string with the initial field chain (e.g. "company_id.name")
/// @param options - an object with several options:
- /// - filters: an object which contains a series of filters to use
- /// - debugMode: a boolean which is true if the widget is in debug mode
+ /// - filters: an object which contains suboptions which determine the fields which are used
+ /// - searchable: a boolean which is true if only the searchable fields have to be used (true by default)
+ /// - debugMode: a boolean which is true if the widget is in debug mode (false by default)
init: function (parent, model, chain, options) {
this._super.apply(this, arguments);
@@ -130,6 +131,9 @@ var ModelFieldSelector = Widget.extend({
filters: {},
debugMode: false,
}, options || {});
+ this.options.filters = _.extend({
+ searchable: true,
+ }, this.options.filters);
this.pages = [];
this.selectedField = false;
@@ -307,7 +311,6 @@ var fieldsCache = {
return this.cacheDefs[model];
},
filter: function (model, filters) {
- filters = _.defaults(filters || {}, {searchable: true});
return _.filter(this.cache[model], function (f) {
return !filters.searchable || f.searchable;
});