Skip to Content
Menú
This question has been flagged
2 Respostes
5318 Vistes

I want to use sql queries in CustomerPortal class controllers. I wrote following code:

request.cr.execute("""my query""")
result = request.cr.fetchall()
but I get the following error:
AttributeError: 'CustomerPortal (extended by PortalAccount, Custome' object has no attribute 'cr'a
what should I do?
Avatar
Descartar
Best Answer

Hello Arian, try to use 'request.session.cr' instead of 'request.cr'.


Avatar
Descartar
Autor

thanks! request.env.cr worked for me aswell.

Best Answer

https://github.com/odoo/odoo/blob/13.0/addons/web/controllers/main.py#L1551

## inside try

registry = odoo.modules.registry.Registry(dbname)
with registry.cursor() as cr:
cr.execute(""" query """)
row = cr.fetchone()
Avatar
Descartar
Related Posts Respostes Vistes Activitat
3
de maig 20
12739
3
d’oct. 15
6529
2
de jul. 25
1398
1
de maig 24
2673
2
de febr. 24
2178