[REF] web: add a hook on Many2XAutocomplete orm promise

closes odoo/odoo#115943

Related: odoo/enterprise#38027
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
Bastien (bvdn)
2023-04-07 19:43:02 +02:00
parent 0b30d1d266
commit f50c7c16ab
@@ -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));