This question has been flagged
6 Replies
6052 Views

Hi,

We need to modify the product search behavior in the "New" quotation page. We need to make it faster, because we have a lot of products (more that 10 millions)

In the "Quotations" page, when the user creates a new quotation and adds a new order line and starts typing in the "Product field", Odoo starts searching automatically while the user is typing. Odoo searches in all the products and takes very long time to respond while the user is typing in the "Product" field.

I have overridden the "product_id_change" method of the "sale.sale_order" class and changed it. However, it did not work!

In order to make the product lookup faster, I want Odoo to get only the product(s) that have "default_code" equal to the value entered in the product field. There is no need to search in other fields such as the product name. How can I achieve this?

Thanks you a lot!!

Avatar
Discard
Best Answer

Ahmed,

Try overriding the name_search() of product_product and in args attribute keep args = [('default_code', 'ilike', name)]:

def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):

    args = [('default_code', 'ilike', name)]

    p_ids= self.search(cr, uid, args, limit=limit, context=context)

    return self.name_get(cr, uid, p_ids, context=context)

Hope it helps!

Avatar
Discard
Author

Thanks my friend ... worked like a charm :)

Best Answer

I face this before in OpenERP 7, there is a few steps that improve the search in many2one fields. Check this:

https://www.odoo.com/es_ES/forum/help-1/question/reason-why-odoo-being-slow-when-there-is-huge-data-inside-the-database-87498#answer-88734

Also I end up modifying the widget to do not trigger the lookup search when the user start typing, just 1sec after the user stop typing. What Odoo version it's affecting you with this?

Avatar
Discard
Author

Thank Axel, I am using Odoo V8. So how did you modify the widget in order not to trigger the lookup search?

In the widget 'instance.web.form.FieldMany2One' on the function render_editable there is delay value for the this.$input.autocomplete() call that in Odoo 8 have the value 200 milliseconds. You could change it to a higher value like 1000 for 1 second. Just create an extension for that widget to change the value