تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
2599 أدوات العرض

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
أغسطس 24
1561
1
مايو 25
1814
2
أبريل 24
1317
0
ديسمبر 23
1451
2
يونيو 21
3092