Odoo Help

Welcome!

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

0

In database how to retrive fields from table

By
Arunkumar
on 8/25/16, 7:25 AM 138 views

hai, i don't know how to retrive data from database

this is my python file

         @http.route('/sample/demo', auth='public',website=True)

         def click(self, **post):

            print "post data===================>",post

            cr = request.cr

            pool = request.registry

            table_name=post.get('t_name',False)

            user_id = post.get('user_id',False)

            response_dict = {}

            jd=[]

            if user_id and table_name:

                        print"Enterloginpage======================="

                        return http.request.render('json.arun1')

            else:

                print "Invalid user_id"

                return http.request.render('json.arunkumar')

--------------------------------------------------------------------------------

    @http.route('/course/datas', auth='public',website=True)

    def index12(self, **post):

            print "post data===================>",post

            cr = request.cr

            print"==============================>"

            # cr.execute("select coursename,coursefee from course_datas")

            cr.execute("select * from table_name")

            res=cr.dictfetchall()

            print "****************",res;

            rect=[]

            if res:

                    jd = json.dumps(res)

                    print "Datas Json",jd

                    return jd

0
yousif Mobark
On 8/27/16, 8:19 AM

hello ,

try the browse(),search() method

browes method it receive the list of  ids  

self.env['course_datas'].browes(ids)

search method receive list of tuples

self.env['course_datas'].search([('coursename','=','math')])

\
 


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/25/16, 7:25 AM
Seen: 138 times
Last updated: 8/27/16, 8:19 AM