How in function create sql statment in odoo 9?
I want call my_function and print all record from database.
For example: select time_start from time where time_start >= 'TODAY''
def my_function(self):
result = []
for data in self.browse():
cr.execute('''select
time_start
from
time
where
time_start >= 'TODAY''')
print all result line by line
Try
cr.dictfetchall()
returns a list of dicts. Every element from this list represents a line in your query-result.In my solution I iterate over this list and can directly access the field by fieldname in database.
Please note, that use query in a loop. Probably there is a better way.
EDIT: Try
search
instead ofbrowse
.browse
gives you the matching records to given ids.