Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
5342 Weergaven

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
Annuleer
Beste antwoord

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


Avatar
Annuleer
Auteur

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

Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
3
mei 20
12767
3
okt. 15
6567
2
jul. 25
1411
1
mei 24
2704
2
feb. 24
2192