[FIX] product: fix _name_search to include dynamic product variants
Targets commit d3530eb07e
Purpose
=======
- The _name_search of product.template fallbacks by default on product.product
In case there are no product.products yet (dynamic product variants configuration), we need to
include the base product.template _name_search in the results
This commit is contained in:
@@ -406,9 +406,23 @@ class ProductTemplate(models.Model):
|
||||
if (not products) or (limit and (len(templates) > limit)):
|
||||
break
|
||||
|
||||
searched_ids = set(templates.ids)
|
||||
# some product.templates do not have product.products yet (dynamic variants configuration),
|
||||
# we need to add the base _name_search to the results
|
||||
# FIXME awa: this is really not performant at all but after discussing with the team
|
||||
# we don't see another way to do it
|
||||
if len(searched_ids) < limit:
|
||||
searched_ids |= set([template_id[0] for template_id in
|
||||
super(ProductTemplate, self)._name_search(
|
||||
name,
|
||||
args=args,
|
||||
operator=operator,
|
||||
limit=limit,
|
||||
name_get_uid=name_get_uid)])
|
||||
|
||||
# re-apply product.template order + name_get
|
||||
return super(ProductTemplate, self)._name_search(
|
||||
'', args=[('id', 'in', list(set(templates.ids)))],
|
||||
'', args=[('id', 'in', list(searched_ids))],
|
||||
operator='ilike', limit=limit, name_get_uid=name_get_uid)
|
||||
|
||||
@api.multi
|
||||
|
||||
Reference in New Issue
Block a user