Skip to Content
Menu
This question has been flagged
2 Replies
10033 Views

I'm trying to create a filter on the 'complete_name' field of res_partner_category which is a function field.

I know that i have to use the fnct_search parameter and implement the function.

My problem is that i don't understand the purpose of this function and i don't know what to write in it !

Maybe someone could explain or give a generic example ?

Avatar
Discard
Best Answer

hi,

https://doc.openerp.com/v6.1/developer/03_modules_2/#functional-fields

you can see example in 'res.groups' :

 def _search_group(self, cr, uid, obj, name, args, context=None):
        operand = args[0][2]
        operator = args[0][1]
        values = operand.split('/')
        group_name = values[0]
        where = [('name', operator, group_name)]
        if len(values) > 1:
            application_name = values[0]
            group_name = values[1]
            where = ['|',('category_id.name', operator, application_name)] + where
        return where

'full_name': fields.function(_get_full_name, type='char', string='Group Name', fnct_search=_search_group),
Avatar
Discard
Author

Thanks for the answer.

I have already read the doc and found some examples in the source code. Despite this i don't understand what is the purpose of that function. Which values are in args (I know that is a list of 3-part tuples reprensanting domain) ? And in which way the returning domain will be used ?

def _search_group(self, cr, uid, obj, name, args, context=None): operand = args[0][2] operator = args[0][1] where = [('name', operator, operand)] return where *** If i want to do a filter to a functional field which has a value either 0 or 1 , then what kind of changes i need to make to the above code.

Author Best Answer

Thanks for the answer.

I have already read the doc and found some examples in the source code. Despite this i don't understand what is the purpose of that function. Which values are in args (I know that is a list of 3-part tuples reprensanting domain) ? And in which way the returning domain will be used ?

Avatar
Discard
Related Posts Replies Views Activity
0
Feb 24
1651
2
Jul 22
5360
2
Mar 21
2951
1
May 24
1910
3
Nov 24
3429