Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
11101 Zobrazení

Hi,

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

Selverine

Avatar
Zrušit

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

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

Nejlepší odpověď

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

Thanks...

Avatar
Zrušit
Autor Nejlepší odpověď

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.

name1,name2,name3

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

Selverine

Avatar
Zrušit
Nejlepší odpověď
Avatar
Zrušit