콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
11105 화면

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

아바타
취소

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.

베스트 답변

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

아바타
취소
작성자 베스트 답변

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

아바타
취소
베스트 답변
아바타
취소