Skip to Content
Menu
This question has been flagged

i success to search with name but i can't do autocompletion when typing  this is my code 

def result2(self, page=0, search=''):
Contacts = http.request.env['res.partner']

# search

domain = []

if search:
domain = [('name', 'ilike', search)]

total_customers = request.env['res.partner'].search(domain)

total_count = len(total_customers)
per_page = 12
pager = request.website.pager(url='/academy/resultat2', total=total_count, page=page, step=per_page, scope=3,
url_args=None)
customers = request.env['res.partner'].search(domain, limit=per_page, offset=pager['offset'], order='id asc')
longueur = len(customers)
values = {
'customers': customers,
'pager': pager,
'contacts': Contacts.search([]),
'valeur': search,
'length': longueur,

}

return request.render('homepage.result2', values)

Avatar
Discard
Best Answer

Hello FEUTSE GAETAN,

To make your search-input act as autocomplete there is no ready-made widget for website, You have to write some JavaScript code for it.
For example you can refer product search bar for eCommerce page. See image below.


https://drive.google.com/file/d/1COOFVsrMrgDO4BoHSOP8qnOOA0p6re9X/view?usp=sharing

You can find technical reference by following file ODOO-14/addons/website_sale/static/src/snippets/s_products_searchbar/000.js.


Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard
Related Posts Replies Views Activity
0
Aug 17
5708
1
Nov 24
44
1
Dec 22
3454
0
Sep 22
743
0
Aug 21
2019