Odoo Help

1

many2one field autocomplete in OpenERP 6.1

By
imad88
on 3/21/13, 8:39 AM 1,980 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--
1018
| 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.

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

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