This question has been flagged
7 Replies
11958 Views

When entering a line on a Sale Order, I click the Search more button and a Product Search view comes up. This search view shows 80 of 160 products. I have about 1200 products loaded into the system. Whatever the logic is that is pulling these 160 items is also effecting default filters applied to that view.

As an example, I set a filter to show all products that have a cost price of 10$ or more which should pull up 502 items, but it only pulls 120 records. If I then un-apply the filter and re-apply it, thien it shows all 502. So, the logic seems to apply when the window is opened, and not at all afterwards. I don't really know where to look for something that would apply in the background, and then disappear...

Avatar
Discard
Best Answer

I solved this using the following js extension:

instance.web.DataSet.include({

name_search: function (name, domain, operator, limit) {

limit = 0;

return this._model.call('name_search', {

name: name || '',

args: domain || false,

operator: operator || 'ilike',

context: this._model.context(),

limit: limit || 0

});

},

});

Avatar
Discard
Author Best Answer

After quite a bit of searching and digging around, I found where this is coded in -

addons/web/static/src/js/view_form.js

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);

});

---------------------

The point which states '160' is the limit of how many items will be pulled up by the Search More window upon initial query. I modified this to be 161 on a dev system just to test and it worked - the list that was pulled up gave me 161 records.

 

Now I need to figure out how to override this as I would rather not mess with the original code.

Avatar
Discard

Kyle, Great that you found that. Very good to know. Here is a link on how to override/extend js code: https://www.odoo.com/forum/help-1/question/how-can-i-extend-a-js-web-module-64

Best Answer

Since this is somewhat hard to track down, one way to check this type of problem is to see what the underlying SQL query is doing. That is simple to view and will shed light on what filters are being applied.

You just need to turn on the postgres logging to show all SQL statements that are run, then do your actions, and then check the postgres log file to see what SQL was run. 

Here is how to enable the logging of SQL statements:

  1. Find your "postgresql.conf" file.  (You can find it by doing the following Query in SQL: "show config_file")
  2. Edit that file and set:
    • log_statement=all   -- usual default is set to "none".
    • OR, other way is to set: log_min_duration_statement = 0
  3. You will need to find out where your log file is. Look for "log_destination" in that same postresql.conf file to help find it. I use the GreenOdoo distro and it logs to /var/odoo8/runtime/psql/logfile
  4. Restart postgresql.

After setting that, do the first product search (also, make sure you are the only user). Then look in the log to see what SQL was executed. There will be a lot of excess SQL which you can skip.  Search for "product_product" or "product_template" which are the tables used for products. From there you can see what filters were appled when quering from the table.

 

Avatar
Discard
Best Answer

Hi,

In Openerp,they set the limit has 80 or 120.you can set the limit in the super method as

res = super(product_product,self).name_search(cr, uid, name, args=args, operator=operator, context=context, limit=limit)

Avatar
Discard
Best Answer

You can also refer to this Github issue: https://github.com/odoo/odoo/issues/2235

Avatar
Discard