diff options
| author | Julien Mougenot <jum@odoo.com> | 2020-07-03 14:02:35 +0000 |
|---|---|---|
| committer | Julien Mougenot <jum@odoo.com> | 2020-07-03 15:48:42 +0000 |
| commit | ff6263dd3f6665ab481c255b607a3e8fc638498c (patch) | |
| tree | a6ba9356976a23288ca5e1b5031e639aa8ceb8e4 /addons/web/static/src/js/control_panel/search_bar.js | |
| parent | 6c97a9eb608eefb423e5811d716b8706fe2859aa (diff) | |
[FIX] web: Support widgets in search view
Since the refactor of the control panel, support of "widgets" attributes
in the search view archs has been inadvertently dropped.
Now, they are once again supported.
Task 2061795
closes odoo/odoo#54066
X-original-commit: f33b0bc7a93e60bd0ed00b40d7459225ec0b749a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/control_panel/search_bar.js')
| -rw-r--r-- | addons/web/static/src/js/control_panel/search_bar.js | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/addons/web/static/src/js/control_panel/search_bar.js b/addons/web/static/src/js/control_panel/search_bar.js index a86e22a10b8..3082c38c055 100644 --- a/addons/web/static/src/js/control_panel/search_bar.js +++ b/addons/web/static/src/js/control_panel/search_bar.js @@ -92,34 +92,41 @@ odoo.define('web.SearchBar', function (require) { * @returns {Object} */ _createSource(filter) { + const field = this.props.fields[filter.fieldName]; + const type = filter.widget || field.type; const source = { active: true, description: filter.description, - fieldName: filter.fieldName, filterId: filter.id, filterOperator: filter.operator, id: sourceId ++, - operator: CHAR_FIELDS.includes(filter.fieldType) ? 'ilike' : '=', + operator: CHAR_FIELDS.includes(type) ? 'ilike' : '=', parent: false, + type, }; - switch (filter.fieldType) { - case 'selection': + switch (type) { + case 'selection': { source.active = false; - source.selection = this.props.fields[filter.fieldName].selection; + source.selection = field.selection || []; break; - case 'boolean': + } + case 'boolean': { source.active = false; source.selection = [ [true, this.env._t("Yes")], [false, this.env._t("No")], ]; break; - case 'many2one': + } + case 'many2one': { source.expand = true; source.expanded = false; + source.context = field.context; + source.relation = field.relation; if (filter.domain) { source.domain = filter.domain; } + } } return source; } @@ -133,7 +140,6 @@ odoo.define('web.SearchBar', function (require) { _createSubSource(source, [value, label], active = true) { const subSource = { active, - fieldName: source.fieldName, filterId: source.filterId, filterOperator: source.filterOperator, id: sourceId ++, @@ -161,16 +167,15 @@ odoo.define('web.SearchBar', function (require) { args = []; } } - const { context, relation } = this.props.fields[source.fieldName]; const results = await this.rpc({ kwargs: { args, - context, + context: source.context, limit: 8, name: this.state.inputValue.trim(), }, method: 'name_search', - model: relation, + model: source.relation, }); const options = results.map(result => this._createSubSource(source, result)); const parentIndex = this.state.sources.indexOf(source); @@ -235,8 +240,7 @@ odoo.define('web.SearchBar', function (require) { * @param {Object} source * @returns {string} */ - _parseWithSource(rawValue, source) { - const { type } = this.props.fields[source.fieldName]; + _parseWithSource(rawValue, { type }) { const parser = field_utils.parse[type]; let parsedValue; switch (type) { |
