Skip to content

Instantly share code, notes, and snippets.

@repodevs
Created February 23, 2017 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save repodevs/8808b24ad8da42cd7d2f5846027ebf24 to your computer and use it in GitHub Desktop.
Save repodevs/8808b24ad8da42cd7d2f5846027ebf24 to your computer and use it in GitHub Desktop.
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