[IMP] website_sale: Add hook for custom search domain
In case we want to search on other fields than name or default_code, or eventually on the descriptions, we need to reverse the domain that is built using AND and OR operators from osv.expression which is something we would prefer to avoid anytime. By adding a hook to add custom domains, it allows to search on whatever extra fields we would like to search on. closes odoo/odoo#159340 X-original-commit: 54c0b97594fb1f489163e993afd0df12cf877501 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
committed by
Victor Feyens
parent
6768cf0613
commit
6e84d601c0
@@ -177,6 +177,9 @@ class WebsiteSale(payment_portal.PaymentPortal):
|
||||
order = post.get('order') or request.env['website'].get_current_website().shop_default_sort
|
||||
return 'is_published desc, %s, id desc' % order
|
||||
|
||||
def _add_search_subdomains_hook(self, search):
|
||||
return []
|
||||
|
||||
def _get_shop_domain(self, search, category, attrib_values, search_in_description=True):
|
||||
domains = [request.website.sale_product_domain()]
|
||||
if search:
|
||||
@@ -188,6 +191,9 @@ class WebsiteSale(payment_portal.PaymentPortal):
|
||||
if search_in_description:
|
||||
subdomains.append([('website_description', 'ilike', srch)])
|
||||
subdomains.append([('description_sale', 'ilike', srch)])
|
||||
extra_subdomain = self._add_search_subdomains_hook(srch)
|
||||
if extra_subdomain:
|
||||
subdomains.append(extra_subdomain)
|
||||
domains.append(expression.OR(subdomains))
|
||||
|
||||
if category:
|
||||
|
||||
Reference in New Issue
Block a user