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]
ids.append(value[1])
elif value[0] == attrib:
ids.append(value[1])
else:
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"/>
</div>
</t>
</t>
</xpath>
</template>