コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
5337 ビュー

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?
アバター
破棄
最善の回答

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


アバター
破棄
著作者

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

最善の回答

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()
アバター
破棄
関連投稿 返信 ビュー 活動
3
5月 20
12757
3
10月 15
6546
2
7月 25
1406
1
5月 24
2690
2
2月 24
2189