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.

1

how to use database cursor in a class That does not inherit from orm.Model ?

By
Nirav Bhadradiya
on 3/13/13, 9:09 AM 2,774 views

How to use database cursor in OpenERPAuthProvider in http_server.py in server part??

2

Nicolas Bessi

--Nicolas Bessi--
1590
| 5 7 8
Lausanne, Switzerland
--Nicolas Bessi--
Nicolas Bessi
On 3/14/13, 5:54 AM

Hello you can do:

from openerp import pooler, sql_db
# Get database connexion
db = sql_db.db_connect(db_name) # You can get the db name from config
cr = db.cursor()

# Access pooler the one in self.pool
pool = pooler.get_pool(cr.dbname)
pool['res.user'].browse...

Hello nbessi, thank you for your useful answer but actually i don't know how to get db_name pro grammatically in my case,,,so it will be very helpful if you will tell me , how to fetch "db_name" from config(which you are saying)... Thank you

Nirav Bhadradiya
on 3/14/13, 6:40 AM

Hello nbessi,,,i have tried your given solution and i have done what i want thank you so much for your help.

Nirav Bhadradiya
on 3/14/13, 9:15 AM

This way i do get access to db but only to some models like res.partner but not to other models like product.product or website ?!? How can i access models like website too?

Michael Karrer
on 3/18/15, 3:06 AM

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: 3/13/13, 9:09 AM
Seen: 2774 times
Last updated: 4/10/15, 1:19 AM