Odoo Help


Select a partner in (Sale, Purchase) order or quotation by email or cell in drop down list.

Faheem Khan
on 11/18/14, 10:12 PM 1,189 views

Select a partner in (Sale, Purchase) order or quotation by email or cell in drop down list for customer field.

Explanation and Example.

When I click to create a new sale order or quotation a form is open to put data. At first I have to select a customer or supplier. When I type a name of customer in drop down a short list is displayed in drop down and at last I saw "search More" and "creat or edit" option. Now if I type email of a customer I only saw "creat or edit" button instead of customer or search more option. If is type some letters of a customer name then I have an option to select search more button then in new window I can search the customer by email but unable to search him in drop down even with cell no, or address or any other field. I can able to search names only in this drop down.

A person give me a code to implement to achive this task but did not explain well, and I am unable to implement this code because I am not a coder so can't understand. I had tried to built a module, module install successfully but without providing me this feature. code is pasted below.

A sample code:

    def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
        if not args:
            args = []
        ids = []
        if name and operator in ('=', 'ilike', '=ilike', 'like', '=like'):
            search_name = name
            if operator in ('ilike', 'like'):
                search_name = '%%%s%%' % name  
            if operator in ('=ilike', '=like'):
                operator = operator[1:]
            query_args = {'name': search_name}
            limit_str = ''
            if limit:
                limit_str = ' limit %(limit)s'
                query_args['limit'] = limit
            search_name = query_args['name']
            cr.execute("SELECT p.id FROM res_partner p WHERE (p.name ilike '" + (search_name or '') + "%') OR (p.ref ilike '" + (search_name or '') + "%') OR (p.mobile ilike '" + (search_name or '') + "%')  OR (p.email ilike '" + (search_name or '') + "%')  ")

            ids = map(lambda x: x[0], cr.fetchall())
            ids = self.search(cr, uid, [('id', 'in', ids)] + args, limit=limit, context=context)
            if ids:
                return self.name_get(cr, uid, ids, context)
        return super(res_partner, self).name_search(cr, uid, name, args, operator=operator, context=context, limit=limit)


Any Help?

Faheem Khan
on 11/23/14, 3:44 AM

Is there no any person who provide me a little help about this issue? Is the question too tough to solve. Please help help help. . . .

Faheem Khan
on 11/23/14, 9:30 PM

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.


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)


Asked: 11/18/14, 10:12 PM
Seen: 1189 times
Last updated: 3/16/15, 8:10 AM