Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
15250 Vizualizări

I'm wondering how to use cr.execute and fetch...? I'm getting only values. Is there a way to get values in a dict?

self.env.cr.execute("SELECT SUM(p.value) AS value, SUM(p.payed) AS payed.....")  # few inner joins and where conditions
result = self.env.cr.fetchall()  

In the result I get (4.66, 2.0), but is there a way to get {'value': 4.66, 'payed': 2.0}?
On only 2 returned values it isn't such a problem but for 5 or more it becomes inconvenient.
(sorry I don't know how to get out of code mode)
Imagine profil
Abandonează
Cel mai bun răspuns

You can use self._cr.dictfetchall()

You can check some more information about python fetch type.

Imagine profil
Abandonează
Autor

Thanks... first time using manual SQL in odoo.

thanks a lot! however, that link gives me 404 page not found, i guess that doesn't work anymore. so instead, here is another link >>> https://www.odoo.com/id_ID/forum/help-1/please-define-these-python-fetch-types-8562

Related Posts Răspunsuri Vizualizări Activitate
1
dec. 19
8374
1
mai 20
6069
2
iul. 25
4686
2
dec. 24
7806
2
nov. 24
28596