temp_list=[]
temp_list.append( self._cr.execute('select * from std_table_print'))
print(temp_list)
here is my code but i am getting a none value as a result
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
temp_list=[]
temp_list.append( self._cr.execute('select * from std_table_print'))
print(temp_list)
here is my code but i am getting a none value as a result
Hello,
for getting the data from the query, after your query you need to write one more line in code.
self._cr.execute("your query") # your query line
from below two line you can use anyone based on your needs.
result = self._cr.fetchall() # return the data into list of tuple format
result = self._cr.dictfetchall() # return the data into the list of dictionary format
into the result variable you can get the data of query
Hello Sourav,
self._cr.execute('select * from std_table_print') this means only the query executed
after that you have to fetch from cursor
self._cr.fetch()
or
self._cr.fetchall()
or
self._cr.fetchone()
It will execute a SQL command and fetch all the data into a list of tuple formats and then convert it into dictionary format.
@api.model
def get_department_employee(self):
cr = self._cr
cr.execute("""select department_id, hr_department.name,count(*)
from hr_employee join hr_department on hr_department.id=hr_employee.department_id
group by hr_employee.department_id,hr_department.name""")
fetch_data = cr.fetchall()
data = []
for i in range(0, len(fetch_data)):
data.append({'label': fetch_data[i][1], 'value': fetch_data[i][2]})
return data
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
2
thg 7 24
|
13927 | ||
|
2
thg 4 23
|
7855 | ||
How to round sum of if code
Đã xử lý
|
|
1
thg 5 22
|
4345 | |
|
2
thg 2 22
|
5014 | ||
|
0
thg 11 21
|
21 |