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

Auto-completion - Odoo 8

By
Alejandro Perez Cosio
on 1/5/15, 3:19 PM 964 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

--Atul Arvind--
1854
| 3 3 5
India
--Atul Arvind--

Hello, 

I am odoo Enthusiast/Consultant from Baroda, Gujarat, India. Working with odoo from v5 to v9 and other opensource technology since 4+ years. Having Strong Expertise in

Requirement gathering & Gap Analysis

Odoo Development

Odoo Customization

Odoo Training

Odoo Integration

Server Administration

Odoo Migration

Implementation

I am also active on StackOverflow.

or 


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

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
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.

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

3 follower(s)

Stats

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