diff options
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/control_panel/control_panel_model.js | 3 | ||||
| -rw-r--r-- | addons/web/static/src/js/control_panel/search_bar.js | 30 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 2 |
3 files changed, 21 insertions, 14 deletions
diff --git a/addons/web/static/src/js/control_panel/control_panel_model.js b/addons/web/static/src/js/control_panel/control_panel_model.js index a9500999793..d09c6eeaa58 100644 --- a/addons/web/static/src/js/control_panel/control_panel_model.js +++ b/addons/web/static/src/js/control_panel/control_panel_model.js @@ -959,6 +959,9 @@ odoo.define('web.ControlPanelModel', function (require) { filter.defaultRank = -10; filter.defaultAutocompleteValue = attrs.defaultAutocompleteValue; } + if (attrs.widget) { // FIXME: drop support in master + filter.widget = attrs.widget; + } break; } } 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) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index fab3018fb46..abe3856b91e 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -604,7 +604,7 @@ </a> <a href="#" t-on-click.prevent=""> <t t-if="src.label" t-esc="src.label"/> - <t t-elif="['date', 'datetime'].includes(props.fields[src.fieldName].type)"> + <t t-elif="['date', 'datetime'].includes(src.type)"> <t>Search <em t-esc="src.description"/> at: <strong t-esc="state.inputValue"/></t> </t> <t t-else="">Search <em t-esc="src.description"/> for: <strong t-esc="state.inputValue"/></t> |
