[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).
This commit is contained in:
qsm-odoo
2017-01-31 11:38:46 +01:00
parent 129be7ff78
commit 3c452a2ecd
3 changed files with 8 additions and 7 deletions
@@ -58,19 +58,18 @@ var DomainNode = Widget.extend({
/// @param domain - an array of the prefix representation of the domain (or a string which represents it)
/// @param options - an object with possible values:
/// - readonly, a boolean to indicate if the widget is readonly or not (default to true)
/// - fs_filters, an object with a series of filters to use for the field selector (see @FieldSelector)
/// - debugMode, a boolean which is true if the widget should be in debug mode (default to false)
/// - @see ModelFieldSelector for other options
init: function (parent, model, domain, options) {
this._super.apply(this, arguments);
this.model = model;
this.options = _.extend({
readonly: true,
fs_filters: {},
debugMode: false,
}, options || {});
this.readonly = this.options.readonly;
this.fs_filters = this.options.fs_filters;
this.debug = this.options.debugMode;
},
/// The getDomain method is an abstract method which should returns the prefix domain
@@ -12,7 +12,6 @@ return Dialog.extend({
this.model = model;
this.options = _.extend({
readonly: true,
fs_filters: {},
debugMode: false,
}, options || {});
@@ -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;
});