Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1120 Lượt xem

I want to stop the website search from searching the 'sales description' field. Any suggestions would be very much appreciated.

I am on Odoo v17 Enterprise on premise.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

In odoo 17 you can check addons code

website_sale/models/product_template.py

check this method 

def _search_get_detail
@api.model
def _search_get_detail(self, website, order, options):
with_image = options['displayImage']
# with_description = options['displayDescription']
with_category = options['displayExtraLink']
with_price = options['displayDetail']
domains = [website.sale_product_domain()]
category = options.get('category')
tags = options.get('tags')
min_price = options.get('min_price')
max_price = options.get('max_price')
attrib_values = options.get('attrib_values')
if category:
domains.append([('public_categ_ids', 'child_of', unslug(category)[1])])
if tags:
if isinstance(tags, str):
tags = tags.split(',')
domains.append([('product_variant_ids.all_product_tag_ids', 'in', tags)])
if min_price:
domains.append([('list_price', '>=', min_price)])
if max_price:
domains.append([('list_price', '<=', max_price)])
if attrib_values:
attrib = None
ids = []
for value in attrib_values:
if not attrib:
attrib = value[0]
ids.append(value[1])
elif value[0] == attrib:
ids.append(value[1])
else:
domains.append([('attribute_line_ids.value_ids', 'in', ids)])
attrib = value[0]
ids = [value[1]]
if attrib:
domains.append([('attribute_line_ids.value_ids', 'in', ids)])
search_fields = ['name', 'default_code', 'product_variant_ids.default_code']
fetch_fields = ['id', 'name', 'website_url']
mapping = {
'name': {'name': 'name', 'type': 'text', 'match': True},
'default_code': {'name': 'default_code', 'type': 'text', 'match': True},
'product_variant_ids.default_code': {'name': 'product_variant_ids.default_code', 'type': 'text', 'match': True},
'website_url': {'name': 'website_url', 'type': 'text', 'truncate': False},
}
if with_image:
mapping['image_url'] = {'name': 'image_url', 'type': 'html'}
# if with_description:
# # Internal note is not part of the rendering.
# search_fields.append('description')
# fetch_fields.append('description')
# search_fields.append('description_sale')
# fetch_fields.append('description_sale')
# mapping['description'] = {'name': 'description_sale', 'type': 'text', 'match': True}
if with_price:
mapping['detail'] = {'name': 'price', 'type': 'html', 'display_currency': options['display_currency']}
mapping['detail_strike'] = {'name': 'list_price', 'type': 'html', 'display_currency': options['display_currency']}
if with_category:
mapping['extra_link'] = {'name': 'category', 'type': 'html'}
return {
'model': 'product.template',
'base_domain': domains,
'search_fields': search_fields,
'fetch_fields': fetch_fields,
'mapping': mapping,
'icon': 'fa-shopping-cart',
}

Comment out 

with_description = options['displayDescription']

condition code and check then override this method in your custom module.

Thanks.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
Website Search bar Đã xử lý
3
thg 4 25
8082
2
thg 9 24
1062
1
thg 7 23
1581
3
thg 1 24
21227
0
thg 5 21
4984