Search with proteus on product.template


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?


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

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

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.

Really weird.
On my database:

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

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

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

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

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

I’ve filed Issue 9229: Improve product template rec_name searcher without variant - Tryton issue tracker which fixes it.

@pokoli: thank you so much