Odoo Help

Welcome!

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.

0

Why this query returning None?

By
samba
on 12/15/14, 2:20 AM 418 views

I am trying to get the sum() saled quantity of a product. For that i write the below query.

out=self.cr.execute(
            """select sum(product_uom_qty) from sale_order_line where product_id=%d and state=%s"""
            %(product_id.id,'done'))

Ther is more than ten sales orders which are there in done state.

product_id is the browse record of product. But it's return None. Can any one tell me how can i get sum of saled quantity of product.

@samba can you post little bit more code, which may help to find the issue. You can try one thing instead of %d, let it be %s, it will not affect your code.

Emipro Technologies Pvt. Ltd.
on 12/15/14, 5:56 AM
1

Bole

--Bole--
2385
| 5 4 6
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole
On 12/15/14, 3:25 AM

hmm... maybe you should try something like...

self.cr.execute("some querry...")
res = cr.fetchall()

in your case out is only a querry, but you didn't fetch any data ...

also.. check this answer 
https://www.odoo.com/forum/help-1/question/how-to-use-cr-execute-to-perform-valid-sql-queries-70200
basicaly.. the same explanation...

Thank you Bole, working fine..

samba
on 12/15/14, 8:02 AM

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

2 follower(s)

Stats

Asked: 12/15/14, 2:20 AM
Seen: 418 times
Last updated: 3/16/15, 8:10 AM