Odoo Help


Please define these Python Fetch types [Closed]

on 3/28/13, 7:26 AM 8,270 views

The Question has been closed

Sudhir Arya (ERP Harbor Consulting Services)
on 04/18/2013 04:47:25

What is the difference between these fetching.? please give me a examples for reference site to get clear idea.still i'm confuse with it

res = cr.dictfetchall()

res2 = cr.dictfetchone()

res3 = cr.fetchall()

res4 = cr.fetchone()

as per below answers this is dictionary

[{'selected_tea_workers_line_ids': 3}, {'selected_tea_workers_line_ids': 5}]

then how to return value from that.?

    return {'value': {
                      'selected_tea_workers_line_ids':? ? ?

refer this

This question has been included in the official documentation.

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 3/28/13, 8:36 AM

cr.dictfetchall() will give you all the matching records in the form of the list of dictionary containing key, value [{'': ''}, {'': ''}, ...].

cr.dictfetchone() works same as cr.dictfetchall() except it returns only a single record {'': ''}.

cr.fetchall() will give you all the matching records in the form of the list of tuple [(''), (''), ...].

cr.fetchone() works same way as cr.fetchall() except it returns only single record ('').

In your given query, the output would be as follow:

  1. cr.dictfetchall() will give you [{'reg_no': 123},{'reg_no': 543},].
  2. cr.dictfetchone() will give you {'reg_no': 123}.
  3. cr.fetchall() will give you '[(123),(543)]'.
  4. cr.fetchone() will give you '(123)'.

+1 for nice explanation & great example.

on 3/28/13, 8:38 AM

Really great answer, thank you very much for your effort.

on 6/18/13, 9:24 AM

Perfect example! Thank you!

on 8/31/13, 5:50 AM

Nice expalantion..Thanks

on 6/25/14, 6:38 AM
This question has been included in the official documentation.
On 3/28/13, 7:38 AM

cr.dictfetchone return {'key':value.....} cr.dictfetchone return [{'key':value.....},{'key':value.....}]

cr.fetchone return [value,value...] cr.fetchall return [[value,value],[value,value]]

thanks DNT :-)

on 3/28/13, 10:26 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 3/28/13, 7:26 AM
Seen: 8270 times
Last updated: 9/15/15, 2:55 AM