Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to modify the product search when creating a new quotation?

By
Ahmed Ababneh
on 10/14/15, 7:59 AM 490 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!!

1

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 10/14/15, 10:12 AM

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!

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

Ahmed Ababneh
on 10/19/15, 4:45 AM
1

Axel Mendoza

--Axel Mendoza--
10323
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 10/14/15, 3:24 PM

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?

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

Ahmed Ababneh
on 10/18/15, 3:46 AM

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

Axel Mendoza
on 10/18/15, 4:29 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 10/14/15, 7:59 AM
Seen: 490 times
Last updated: 10/19/15, 4:45 AM