Hi,
I would like to select a customer from the select box by start typing its phone number.
How can I do that?
I have seen that we can use name_search method how to use it, both back end and frond end ?
Is anyone know this?
Thanks in advance.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
I would like to select a customer from the select box by start typing its phone number.
How can I do that?
I have seen that we can use name_search method how to use it, both back end and frond end ?
Is anyone know this?
Thanks in advance.
Hi Silpa,
You can achieve it using a combination of _rec_name,name_search and name_get methods as follows:
1. You need to define _rec_name like:
_rec_name = 'mobile'
2. Need to override name_search as:
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
res = super(res_partner,self).name_search(cr,user,name,args,operator,context,limit)
if not res:
ids = self.search(cr, user, [('mobile',operator,name)], limit=limit, context=context)
res = self.name_get(cr, user, ids, context=context)
return res
3. Need to override name_get as:
def name_get(self, cr, uid, ids, context=None):
if context is None:
context = {}
if isinstance(ids, (int, long)):
ids = [ids]
res = []
reads = self.read(cr, uid, ids, ['name', 'mobile'], context=context)
for record in reads:
if record['name']:
name = record['name']
res.append((record['id'], name))
return res
Hi Silpa,
You have to use particular filter_domain in search view:
Inherit the res.partner search view and then add this line:
<field name="phone" filter_domain="['|',('phone','ilike',self)]"/>
Hope This WilL Help You. Give Thumps up.!
Thanks,
ChanDni.
Hi ChanDni,
Thank you for your answer.And what i need is to select a customer in select box or many2one field in another form.
I am not getting what actual your requirement is. Select Customer in select box? !! and many2one field can be there in another form. What functionality you want?
i have a form with many2one field(customer selection box) and if i have 2 customers with same name like 'A' so i need to search a customer with his mobile number with in that selection box.
Then you should use the name_get method. Inherit the object res.partner and overwrite the method name_get:
@api.multi
def name_get(self):
result = super(res_partner,self).name_get()
for record in self:
....
your code...
....
return .....
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 12 18
|
2684 | ||
|
2
thg 10 18
|
7513 | ||
|
1
thg 12 16
|
6730 | ||
|
1
thg 8 16
|
3552 | ||
|
1
thg 5 16
|
3236 |