콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2800 화면

i am trying ecommerce shop using odoo13 ce.

my problem is
shop search bar can search internal reference but can not search barcode.
how to search include barcode from shop search bar?

Thanks

아바타
취소

Do you mean that shop visitors enter a 13 digit barcode for example?

작성자

yes,

visitors enter a 13 digit barcode

베스트 답변

Hi,

If you need to search the products with barcode in the website, you have to inherit and modify the function named: _get_search_domain inside the website_sale module.


def _get_search_domain(self, search, category, attrib_values, search_in_description=True):
domains = [request.website.sale_product_domain()]
if search:
for srch in search.split(" "):
subdomains = [
[('name', 'ilike', srch)],
[('product_variant_ids.default_code', 'ilike', srch)]
]
if search_in_description:
subdomains.append([('barcode', 'ilike', srch)])
subdomains.append([('description', 'ilike', srch)])
subdomains.append([('description_sale', 'ilike', srch)])
domains.append(expression.OR(subdomains))

In the above code sample, you can see that i have added barcode field to search. So you can inherit the above in a custom module and make necessary changes,

For reference:
1. Inheriting controllers in odoo
2. Q Context in Odoo

Thanks

아바타
취소
관련 게시물 답글 화면 활동
1
8월 24
1710
1
5월 25
2039
2
4월 24
1556
0
8월 25
1743
2
6월 21
3370