Odoo Help


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.


How to access cr or database in httprequest in openerp 7?

Praveen Shakkarval
on 3/2/16, 5:07 PM 338 views

I want to access database in my below method in openerp 7:


def index(self, req, data, token):

data = json.loads(data)

model = data.get('model', [])

columns_headers = data.get('headers', [])

rows = data.get('rows', [])

return req.make_response(

self.from_data(columns_headers, rows),


('Content-Disposition', 'attachment; filename="%s"'

% self.filename(model)),

('Content-Type', self.content_type)


cookies={'fileToken': token}


I accessed database in odoo 8 using request.cr in same method.

but here when I tried req.cr and used it too access method, it throws error

cr is not attribute of request.

So tell me a way to access either cr or database somehow.


Axel Mendoza

--Axel Mendoza--
| 6 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 3/2/16, 7:50 PM

You could do it like:

registry = openerp.modules.registry.Registry(dbname)
with registry.cursor() as cr:
    cr.execute("""SELECT * from res_users""")

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)


Asked: 3/2/16, 5:07 PM
Seen: 338 times
Last updated: 3/10/16, 2:52 AM