Odoo Help

1

Auto-completion - Odoo 8

By
Alejandro Perez Cosio
on 1/5/15, 3:19 PM 1,463 views

Hello, 

On sales order, I would like to select a partner from the select box by start typing its phone number.
How can I do that?

Thank you in advance!
Regards

1
Atul Arvind
On 1/6/15, 4:44 AM

_name_search method will allow to customize the search based on other field.
to search based on phone filed you need to override the method of res_partner like

    def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
        if not context: context={}
        res = super(res_partner, self). name_search(cr, user, name, args=args, operator=operator, context=context, limit=limit)
        if name:
            ids = self.search(cr, user, [('phone','=',name)]+ args, limit=limit, context=context)
        if ids:
            res = self.name_get(cr, user, ids, context=context)
        return res
        
it will give you partner when you search related partner phone.

@Atul, it is more performant if you just add the args before calling the super. Then, it will only search once. Also, I think you shouldn't return the return of name_get.

Ivan
on 1/6/15, 6:25 AM
1
Ivan
On 1/6/15, 4:12 AM

You need to enhance the name_search method of res.partner to also search the phone number field.  You may want to enhance the name_get method as well to display the phone number field.

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

3 follower(s)

Stats

Asked: 1/5/15, 3:19 PM
Seen: 1463 times
Last updated: 5/21/16, 1:51 PM