Search code examples
javascriptpython-2.7odooodoo-10

Why does search view shows only 160 items?


enter image description hereIn customer master, when I entering the state I clicked search more option. It lists only 160 items where actually it contains more than that. So I checked it found that the search view only list 160 items even the master file contain more than that.

addons/web/static/src/js/views/form_common.js

dataset.name_search(search_val, self.build_domain(), 'ilike', 160).done(function(_data) {
    self._search_create_popup("search", _data);
}        `

When changing 160 to 161, the search form shows 161 items.

So how can I set this to unlimited (ie. as much as the items there) and moreover is it safe to change the value within Odoo? Or how can I do this in other way?

Thanks in advance


Solution

  • On the Partner form, the State field has a domain that is enforced if your partner has their Country selected. This means that if you choose "United States" as the Country, then it will only show States that also have a Country of "United States"

    However, even when the Country is not selected, it will still restrict the number of States shown in the Search more... popup.

    I'm not sure why, but if you:

    1. Click the Search... bar in that popup window
    2. Press Enter (to re-search the list)

    Then it will return all available States...

    It seems that this is a known issue with no plan to fix (at least not to backport to stable versions once it is fixed). See these Github Issues reports (below). This still exists on Odoo 11, even on demo.odoo.com

    1. Search more unpredictable
    2. [V8] only 80 of 160 taxes are shown: reality 2651

    There are ways to work around this issue, but it requires modifying the JavaScript (as you mentioned it in your question, you may have some idea about this already). You can see this question on the Odoo forum, which has a couple of snippets.

    Basically, the solution requires overriding the name_search function out of addons/web/static/src/js/framwork/data.js

    name_search: function (name, domain, operator, limit) {
        # This is the magic
        limit = 0;
        # Just the above line
        return this._model.call('name_search', {
            name: name || '',
            args: domain || false,
            operator: operator || 'ilike',
            context: this._model.context(),
            limit: limit || 0
        });
    },
    

    Note: This will globally affect all of your Odoo. If you want to restrict it to only one form (or some other criteria), then you must do so with whatever view/template you use to define your JavaScript import.


    Previous Answer

    The normal way to modify that is to change the default limit of a Window Action in XML or the GUI and it will show more or less records by default.

    1. Enable Developer Mode
    2. Navigate to the Tree View that you want to remove limit from
    3. Click the “Debug” button (bug icon in top right of Odoo, next to user name)
    4. Click “Edit Action”
    5. Change the “Limit” value and save
      • Limit of 0 or -1 should achieve an unlimited list, but you may need to test a couple of different values to see which works best.
      • If those don’t work well, then you can change Limit to 999999 or something higher than will ever conceivably be reached.

    Notes:

    1. You can also define that limit change via XML on the Action.

       <field name=“limit”>0</field>
      
    2. You can also set the limit attribute on a tree element directly.

      Again, you may have to test this to see which value provides the unlimited list, but you can use it like this (in the tree view XML definition):

       <tree id=“...” string=“...” limit=“0”/>