0

There is a field product_id in sale.order.line model that is a Many2One field. There are a ton of product data inside the database. Right now, when a user fills in some characters, it will suggest some records filtered by the given characters. However, it is limited to only 7 records with a search more option underneath it.

My question is how to customize it so that it will return any number of records? (I will fine-tune later to come up with the number of satisfied limit)

I have tried messing with Autocomplete widget and FieldMany2One in the javascript files, but to no avail.

holydragon
  • 6,158
  • 6
  • 39
  • 62
  • 1
    You can use a ready solution, but it comes with more than only this requirement: [web_m2x_options by OCA](https://github.com/OCA/web/tree/14.0/web_m2x_options). – CZoellner Apr 05 '23 at 13:47

1 Answers1

1

The limit is hard coded in init function

You can alter the FieldMany2One widget and make it possible to set the limit in the field options

Example:

var relationalFields = require('web.relational_fields');

relationalFields.FieldMany2One.include({
    init: function (parent, name, record, options) {
        this._super.apply(this, arguments);
        this.limit = this.nodeOptions.limit || this.limit;

    },
});

To set the limit to 10, just set the limit like following:

options="{'limit': 10}"
Kenly
  • 24,317
  • 7
  • 44
  • 60