Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
8420 มุมมอง

How would you go about changing the website search bar to include custom information and make it posible to search on custom information? 

อวตาร
ละทิ้ง
ผู้เขียน

i will try and see how it works, Thanks! 

ผู้เขียน คำตอบที่ดีที่สุด

Soo i figured it out by myself

inherit product.template and run the function and then just append to  search_fields


 @api.model    
 def_search_get_detail(self, website, order, options):            
    search_details = super(ProductTemplate, self)._search_get_detail(website, order, options)
 search_details['search_fields'].append('your products')


   




อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Martin,

Would you please explain to me where you have made this edit?
I am fairly new to Odoo but I have the exact same problem you had!
Thanks in advance!
Twan

search_details['search_fields'].append('your products')
อวตาร
ละทิ้ง
ผู้เขียน

Hi,
I would try and override the product.template metod at:
https://github.com/odoo/odoo/blob/3a28e5b0adbb36bdb1155a6854cdfbe4e7f9b187/addons/website_sale/models/product_template.py#L348

And then just append the attributes you need to search_fields

คำตอบที่ดีที่สุด

Hello

Following method may help you to change search behaviour of default odoo website. 

def _search_with_fuzzy(self, search_type, search, limit, order, options):
"""
Performs a search with a search text or with a resembling word

:param search_type: indicates what to search within, 'all' matches all available types
:param search: text against which to match results
:param limit: maximum number of results per model type involved in the result
:param order: order on which to sort results within a model type
:param options: search options from the submitted form containing:
- allowFuzzy: boolean indicating whether the fuzzy matching must be done
- other options used by `_search_get_details()`

:return: tuple containing:
- count: total number of results across all involved models
- results: list of results per model (see _search_exact)
- fuzzy_term: similar word against which results were obtained, indicates there were
no results for the initially requested search
"""

Thanks & Regards,



CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat 380015
    

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
มี.ค. 24
5663
1
มี.ค. 24
2018
2
ธ.ค. 23
1732
Website form default country แก้ไขแล้ว
1
ก.ย. 22
4205
2
ก.ค. 22
2731