Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

fnct_search new API implementation

By
Mandeep
on 11/24/14, 12:01 PM 777 views

I am trying to implement a custom search method on a field using the following code. However search method (word_search) is never being called(using Advanced Search). I tried to go through the new api docs and have tried to model the method in a similar way. Not sure what is going wrong here.

class myclass(models.Model):

    _name = "myclass"
    myfield = fields.Char(string='Word', size=100, required=True)

    @api.model          

    def word_search(self, operator, operand):
       _logger.info("search function called %s" % operand)
       ids=[]
       domain = [('id', 'in', ids)]
       return domain  # e.g. [('id', 'in', ids)]

    searchfield = fields.Text(compute = "anothermethod", store='False', string="Match Expression", search='word_search')

Any ideas please. Why isnt this method being called

Mandeep
on 11/24/14, 10:56 PM

Have you tried removing @api.model ? Since this is your own class, you don't need to make your function available to the old api, so @api.model is not required. Just to check: you made your advanced search on "searchfield" not on "myfield", right?

Nicolas PIGANEAU
on 11/25/14, 3:22 AM

Thanks. This is fixed. Changing store='False' to store=False fixed this

Mandeep
on 11/25/14, 4:22 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 11/24/14, 12:01 PM
Seen: 777 times
Last updated: 3/16/15, 8:10 AM