There is an edit that I made on the search more option, I need it to be shown all the time, in odoo 14, i made it by this code :
odoo.define('customized_m2o_widget.Fields', function (require) {
"use strict";
var relational_fields = require('web.relational_fields');
var FieldMany2One = relational_fields.FieldMany2One;
FieldMany2One.include({
_search: async function (searchValue = "") {
const value = searchValue.trim();
const domain = this.record.getDomain(this.recordParams);
const context = Object.assign(
this.record.getContext(this.recordParams),
this.additionalContext
);
var values = await this._super.apply(this, arguments);
if (this.limit >= values.length || this.limit < values.length) {
values = this._manageSearchMore(values, value, domain, context);
}
return values;
},
})
});
now I need to migrate to odoo 16, so anyone have a way to do it in the write syntax and semantic code to let it works again? thanks in advance
Try to patch the many2one_field widget and set the search limit to -1
Example:
/** @odoo-module **/
import {patch} from "@web/core/utils/patch";
import {Many2OneField} from "@web/views/fields/many2one/many2one_field";
patch(Many2OneField.prototype, "Many2OneField.SearchMore", {
get Many2XAutocompleteProps() {
return {
...this._super(...arguments),
searchLimit: -1,
};
}
});
Add the following entry to the manifest file:
'assets': {
'web.assets_backend': [
'MODULE_NAME/static/src/js/many2one_search_more.js',
],
},
Update
Inherit relational_utils
to override loadOptionsSource
function
Example:
import {patch} from "@web/core/utils/patch";
import { Many2XAutocomplete } from "@web/views/fields/relational_utils"
patch(Many2XAutocomplete.prototype, "Many2XAutocomplete.SearchLimit", {
async loadOptionsSource(request) {
var options = this._super(request);
return options;
}
});