Created
February 23, 2017 10:26
-
-
Save repodevs/8808b24ad8da42cd7d2f5846027ebf24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cr = self.env.cr | |
sql = 'select product_id, location_id, sum(qty) from stock_quant where location_id != 9 group by location_id, product_id order by product_id asc limit 10' | |
cr.execute(sql) | |
cr.dictfetchall() | |
""" | |
Example Output: | |
[{'sum': 4.0, 'location_id': 19, 'product_id': 13}, {'sum': 1.0, 'location_id': 12, 'product_id': 13}, {'sum': 20.0, 'location_id': 19, 'product_id': 14}, {'sum': 2.0, 'location_id': 12, 'product_id': 14}, {'sum': 3.0, 'location_id': 19, 'product_id': 15}, {'sum': 3.0, 'location_id': 12, 'product_id': 16}, {'sum': 6.0, 'location_id': 19, 'product_id': 16}, {'sum': 28.0, 'location_id': 19, 'product_id': 17}, {'sum': 3.0, 'location_id': 19, 'product_id': 18}, {'sum': 6.0, 'location_id': 12, 'product_id': 18}] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment