From f50c7c16abb77894fce1916e1eec4624f7ec4cf7 Mon Sep 17 00:00:00 2001 From: "Bastien (bvdn)" Date: Mon, 20 Mar 2023 17:45:42 +0000 Subject: [PATCH] [REF] web: add a hook on Many2XAutocomplete orm promise closes odoo/odoo#115943 Related: odoo/enterprise#38027 Signed-off-by: Xavier Bol (xbo) --- .../static/src/views/fields/relational_utils.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/views/fields/relational_utils.js b/addons/web/static/src/views/fields/relational_utils.js index 135a49c17ba..9736c83a0dd 100644 --- a/addons/web/static/src/views/fields/relational_utils.js +++ b/addons/web/static/src/views/fields/relational_utils.js @@ -226,6 +226,15 @@ export class Many2XAutocomplete extends Component { this.props.update([record], params); } + search(name) { + return this.orm.call(this.props.resModel, "name_search", [], { + name: name, + operator: "ilike", + args: this.props.getDomain(), + limit: this.props.searchLimit + 1, + context: this.props.context, + }); + } mapRecordToOption(result) { return { value: result[0], @@ -236,13 +245,7 @@ export class Many2XAutocomplete extends Component { if (this.lastProm) { this.lastProm.abort(false); } - this.lastProm = this.orm.call(this.props.resModel, "name_search", [], { - name: request, - operator: "ilike", - args: this.props.getDomain(), - limit: this.props.searchLimit + 1, - context: this.props.context, - }); + this.lastProm = this.search(request); const records = await this.lastProm; const options = records.map((result) => this.mapRecordToOption(result));