summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/control_panel
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2020-07-03 14:02:35 +0000
committerJulien Mougenot <jum@odoo.com>2020-07-03 15:48:42 +0000
commitff6263dd3f6665ab481c255b607a3e8fc638498c (patch)
treea6ba9356976a23288ca5e1b5031e639aa8ceb8e4 /addons/web/static/src/js/control_panel
parent6c97a9eb608eefb423e5811d716b8706fe2859aa (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')
-rw-r--r--addons/web/static/src/js/control_panel/control_panel_model.js3
-rw-r--r--addons/web/static/src/js/control_panel/search_bar.js30
2 files changed, 20 insertions, 13 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) {