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.

1

How to implement fnct_search ?

By
Anne-Sylvie Burri
on 9/3/13, 5:57 AM 3,653 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 ?

3

Borni DHIFI

--Borni DHIFI--
5102
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

Borni DHIFI
On 9/3/13, 6:28 AM

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),

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 ?

J.-M. Burri - Bureau ing.-conseils informatique, Anne-Sylvie Burri
on 9/4/13, 6:25 AM

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.

A V
on 9/8/13, 8:47 AM
0
Anne-Sylvie Burri
On 9/4/13, 4:13 AM

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 ?

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

0 follower(s)

Stats

Asked: 9/3/13, 5:57 AM
Seen: 3653 times
Last updated: 3/16/15, 8:10 AM