Odoo Help


Print the result of an SQL queries

on 1/7/14, 8:04 PM 3,745 views


Is it possible to print the result of an SQL queries?

For exemple my SQL queries will send me the name of 10 products. I would like to have a tree with a line for each result.

Is it possible? If yes how? With a field type function? How can I put in my field the names of the 10 products? How can I print it?

Thanks a lot


have you tried creating a view from sql query? and yes you are creating a module right?.

Vitap ramdevputra
on 1/8/14, 12:38 AM

You can use functional fields to show one2many and many2many fields, where the values are fetched using ORM methods or SQL queries.

Gopakumar N G
on 1/8/14, 2:45 AM

Pinakin Nayi (pna)

--Pinakin Nayi (pna)--
| 2 2 5
Ahmedabad, India
--Pinakin Nayi (pna)--

He has good skills in problem identification and implementation of effective solutions. He is working in RD India validation team.

Skype: pinakinerp

LinkedIn : https://www.linkedin.com/in/pinakin-nayi-2a33103a/


Pinakin Nayi (pna)
On 1/8/14, 5:47 AM

Hi, I think you want to display SQL result in dynamic tree which is dependent on query.. I think its possible through js, you can find same functionality in import when we import any csv its fetch data and display in dynamic table..


On 1/8/14, 6:29 AM

Hi Pinakin, Vitap, Gopakumar,

Thank you for your comments.

For the moment I succeed in storing the result of my SQL queries in a field type text.

cr.execute('SELECT name from product_bat where name is not null')
res = cr.fetchall()
result['product_BAT'] = res

'product_BAT': fields.text('product.bat'),

<field name="product_BAT"/>

The problem is that I have the list of my result in one line, seperate by some coma.


Is it possible to store my result not in field.text but in a field that will print a tree with one line per result?

To Vitap Ramdevputra : For the moment I try to write directly in a common module but yes, in the futur I will create my own module.

To Gopakumar N G : Is with this kind of fields (one2many, many2many) that I will have a tree? I try to modify the fields in one2many but I don't succeed to store the result of my SQL Queries in this kind of type

To Pinakin Nayi : I will try to see how it works and I will get in touch.

Edit: I still have this problem and I am little deseperate so..if someone have an idea it will be a really good help.

Thank you again a lot


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: 1/7/14, 8:04 PM
Seen: 3745 times
Last updated: 3/16/15, 8:10 AM