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
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?
Thanks. This is fixed. Changing store='False' to store=False fixed this