Community mailing list archives

Re: Odoo 8 computed field issue

Yassine TEIMI
- 11/20/2015 09:50:16
Hi Nick, 

I used fetchone() to fetch my query results, it returns a list of tuples, here is my code : 

      "select value_number from survey_user_input_line where col_label='Resultat' and value_suggested_row=115 and user_input_id=178")
                res =
                result = res[0][0]

and here is my error : 

   result = res[0][0]
TypeError: 'NoneType' object has no attribute '__getitem__'

2015-11-20 14:44 GMT+00:00 Nick Booker <>:
Hi Yassine.

Yassine Teimi <> writes:

> On the other hand, do you have an idea what kind of return does :
>'sql suery') ?

It returns nothing useful.

Do cr.fetchall() to get a list of tuples containing the results.

There's also cr.fetchone() and cr.fetchmany().

See also:

> And how to use sql query parameters ? explicitly, how to use variables
> on the sql query ?

    'SELECT x, y, z FROM table WHERE name = %s AND state = %s',
    (myname, mystate)

for x, y, z in cr.fetchall():
    # do something with x, y and z

Post to:



Yassine TEIMI

Consultant & Odoo Project Manager
TEL : +212 6-87 71 41 18