Odoo Many2one Search More than160 records

On a many2one to a model when we click Search More... the hardcoded limit from Odoo in this search is 160 records, while there are more on the table. (in my example 2820 records)


Eventually, the search views are hard code limited to 160 records.

On Odoo 9 It is under /web/static/src/js/views.js like this:

            // search more... if more results that max
            if (values.length > self.limit) {
                values = values.slice(0, self.limit);
                values.push({
                    label: _t("Search More..."),
                    action: function() {
                        dataset.name_search(search_val, self.build_domain(), 'ilike', 160).done(function(data) {
                            self._search_create_popup("search", data);
                        });
                    },
                    classname: 'oe_m2o_dropdown_option'
                });
            }

On Odoo12 it is on odoo/addons/web/static/src/js/fields/relational_fields.js

// search more... if more results than limit
                if (values.length > self.limit) {
                    values = values.slice(0, self.limit);
                    values.push({
                        label: _t("Search More..."),
                        action: function () {
                            self._rpc({
                                    model: self.field.relation,
                                    method: 'name_search',
                                    kwargs: {
                                        name: search_val,
                                        args: domain,
                                        operator: "ilike",
                                        limit: 160,
                                        context: context,
                                    },
                                })
                                .then(self._searchCreatePopup.bind(self, "search"));
                        },
                        classname: 'o_m2o_dropdown_option',
                    });
                }


If you can inherit the core JS file, then make and addon to replace the widget , or else just modify the above code and change the 160 limit or just comment the limit.




Odoo Many2one Search More than160 records
vitraining, odoo indonesia
24 June, 2020
Share this post
Archive
Sign in to leave a comment
Interfacing Python, Odoo, dengan SATO Barcode Printer