Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to search and read records in OpenERP/Odoo ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 972
    Answer it

    Odoo provides a search_read() shortcut which as its name notes is equivalent to a search() followed by a read(), but avoids having to perform two requests and keep ids around.for example code is like below.

    models.execute_kw(db, uid, password,
        'res.partner', 'search_read',
        [[['is_company', '=', True], ['customer', '=', True]]],
        {'fields': ['name', 'country_id', 'comment'], 'limit': 5})
    [
        {
            "comment": false,
            "country_id": [ 21, "Belgium" ],
            "id": 7,
            "name": "Agrolait"
        },
        {
            "comment": false,
            "country_id": [ 76, "France" ],
            "id": 18,
            "name": "Axelor"
        },
        {
            "comment": false,
            "country_id": [ 233, "United Kingdom" ],
            "id": 12,
            "name": "Bank Wealthy and sons"
        },
        {
            "comment": false,
            "country_id": [ 105, "India" ],
            "id": 14,
            "name": "Best Designers"
        },
        {
            "comment": false,
            "country_id": [ 76, "France" ],
            "id": 17,
            "name": "Camptocamp"
        }
    ]

    Note- Its arguments are similar to search()'s, but it can also take a list of fields (like read().

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: