Searching many2one field

Asked by Erik Myllymaki

What is the proper way to search on a many2one field?

This method works with one2many field (product.seller_id):

product_ids = oerp.search('product.product', [('seller_ids', '=', '1')])

but the same form does not work with a many2one field.

Question information

Language:
English Edit question
Status:
Answered
For:
OERPLib Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
S├ębastien Alix (sebastien-alix) said :
#1

Hi Erik,

Nothing is wrong about your code, nor with OERPLib :)
In fact, the 'seller_id' field of the 'product.product' model is a 'fields.function' without a search function defined, making it a no-searchable field for OpenERP (it is the default behaviour of a field function).

Try to override this field in a custom module and implement the 'fnct_search' parameter for this field:
https://doc.openerp.com/trunk/server/03_module_dev_02/#functional-fields

Regards,

Can you help with this problem?

Provide an answer of your own, or ask Erik Myllymaki for more information if necessary.

To post a message you must log in.