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.

1

many2one field autocomplete in OpenERP 6.1

By
imad88
on 3/21/13, 8:39 AM 1,700 views

Hello everybody, In many2one field, when I put some caracters the autocomplete return all strings contains these caracters. For example if I put "ma" the autocomplete return ("image","manager","roma" ...). What I want is that the autocomplete must return exactly the sting which start with for example "ma" not witch contains "ma" in everywhere (at first, middle or last). So where and which file I must modify. Thank you.

Do you need this feature for all many2one fields or only for a particular object ?

saad
on 3/21/13, 12:25 PM

I need it for a particular object.

imad88
on 3/21/13, 6:55 PM
2

saad

--saad--
1008
| 5 4 8
Casablanca, Morocco
--saad--
saad
On 3/22/13, 12:46 PM

I suggest you to override the name_search() method of your object like that:

def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
    if not args:
        args = []
    if context is None:
        context = {}
    ids = []
    name = name + '%'
    cr.execute("SELECT id FROM your_object_table WHERE name like %s", (name,))
    ids = cr.dictfetchall()
    return self.name_get(cr, uid, ids, context)

let me know if it works

Thank you very much brother :) it works perfectly ;) thanks again.

imad88
on 3/22/13, 1:08 PM

hey should we create another table for that field?

supreeth
on 9/9/15, 6:06 AM

hey should we create another table/class for that field? I need it for particular object

supreeth
on 9/9/15, 6:07 AM

hey should we create another table/class for that field? I need it for particular object

supreeth
on 9/9/15, 6:07 AM
0
imad88
On 3/22/13, 7:44 AM

I need it for a particular object.

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

1 follower(s)

Stats

Asked: 3/21/13, 8:39 AM
Seen: 1700 times
Last updated: 3/16/15, 8:10 AM