# Search with proteus on product.template

**URL:** https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593
**Category:** Developer
**Created:** [April 16, 2020, 6:44am UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593 "2020-04-16T06:44:23Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![2cadz](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/2cadz/32/130_2.png) [@2cadz](https://discuss.tryton.org/u/2cadz)
#### Post date: [April 16, 2020, 6:44am UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593/1 "2020-04-16T06:44:23Z")

</div>

Hi,

If I do a search on the field ‘rec\_name’ of ‘product\_template’ (what the import\_data method of modelstorage does) it does not return any element while on the field ‘name’ it returns the records. On this object the field ‘rec\_name’ cannot be used in a search?

regards.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 16, 2020, 7:10am UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593/2 "2020-04-16T07:10:01Z")

</div>

> [@2cadz](#):
>
> If I do a search on the field ‘rec\_name’ of ‘product\_template’ (what the import\_data method of modelstorage does) it does not return any element while on the field ‘name’ it returns the records.

It’s strange, I did a test and it get the same results using name and using rec\_name:

```python
>>> from proteus import Model, config
>>> config.set_trytond()
>>> Template = Model.get('product.template')
>>> len(Template.find([('rec_name', 'ilike', '%paper%')]))
12
>>> len(Template.find([('name', 'ilike', '%paper%')]))
12

```

> [@2cadz](#):
>
> On this object the field ‘rec\_name’ cannot be used in a search?

No, normally we implement a meaningull rec\_name and it’s searcher for most of the models.  
Indeed we [improved the template rec\_name searcher recently](https://hg.tryton.org/modules/product/rev/b98cd0632102).

---

<div class="post-metadata">

### Author: ![2cadz](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/2cadz/32/130_2.png) [@2cadz](https://discuss.tryton.org/u/2cadz)
#### Post date: [April 16, 2020, 12:15pm UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593/3 "2020-04-16T12:15:51Z")

</div>

Really weird.  
On my database:

```auto
>>> len(Template.find([('rec_name', 'ilike', '%2%')]))
0
>>> len(Template.find([('name', 'ilike', '%2%')]))
14

```

---

<div class="post-metadata">

### Author: ![2cadz](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/2cadz/32/130_2.png) [@2cadz](https://discuss.tryton.org/u/2cadz)
#### Post date: [April 16, 2020, 12:20pm UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593/4 "2020-04-16T12:20:18Z")

</div>

Something to think about: the product models were created by importation. On models created by the interface it works.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [April 16, 2020, 12:37pm UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593/5 "2020-04-16T12:37:22Z")

</div>

Template record name search is implemented to search via the products. So if your template has no product it can not find them.

---

<div class="post-metadata">

### Author: ![2cadz](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/2cadz/32/130_2.png) [@2cadz](https://discuss.tryton.org/u/2cadz)
#### Post date: [April 16, 2020, 12:48pm UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593/6 "2020-04-16T12:48:21Z")

</div>

Ok, so it is not possible to import models and then products (aka variants)?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [April 16, 2020, 1:56pm UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593/7 "2020-04-16T13:56:20Z")

</div>

I guess the search methods for `Template` and `Product` `rec_name` must be improved to works in such case.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 16, 2020, 2:53pm UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593/8 "2020-04-16T14:53:37Z")

</div>

I’ve filed [Improve product template rec\_name searcher without variant (#9229) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue9229) which fixes it.

---

<div class="post-metadata">

### Author: ![2cadz](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/2cadz/32/130_2.png) [@2cadz](https://discuss.tryton.org/u/2cadz)
#### Post date: [April 22, 2020, 2:31pm UTC](https://discuss.tryton.org/t/search-with-proteus-on-product-template/2593/9 "2020-04-22T14:31:53Z")

</div>

@pokoli: thank you so much
