Odoo Help

Welcome!

This community 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.

0

website_sale search function

By
Christelle Wehbe
on 11/11/15, 7:43 AM 452 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]
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>


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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