Odoo Help


website_sale search function

Christelle Wehbe
on 11/11/15, 7:43 AM 859 views

I want to expand the search function in website_sale to be able to search on a tag in the products_item.

Anyone who knows how to do it?

Here is my code:

You can see that I have added ('image_tags', 'ilike', srch), that I have created in another module.

class website_sale(website_sale):

def _get_search_domain(self, search, category, attrib_values):
domain = request.website.sale_product_domain()

if search:
for srch in search.split(" "):
domain += [
'|', '|', '|', ('name', 'ilike', srch), ('description', 'ilike', srch),
('description_sale', 'ilike', srch), ('product_variant_ids.default_code', 'ilike', srch),
('image_tags', 'ilike', srch)]

if category:
domain += [('public_categ_ids', 'child_of', int(category))]

if attrib_values:
attrib = None
ids = []
for value in attrib_values:
if not attrib:
attrib = value[0]
elif value[0] == attrib:
domain += [('attribute_line_ids.value_ids', 'in', ids)]
attrib = value[0]
ids = [value[1]]
if attrib:
domain += [('attribute_line_ids.value_ids', 'in', ids)]

<template id="product_view_tags" inherit_id="website_sale.products_item">
<xpath expr="//div[@itemprop='offers']" position="after">
<t t-if="product.image_tags">
<t t-foreach="product.image_tags" t-as="tag">
<div class="text-info oe_subdescription" contenteditable="false">
<div itemprop="image_tags" t-field="tag.name"/>

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/11/15, 7:43 AM
Seen: 859 times
Last updated: 11/11/15, 7:43 AM